c# - How do I display all contents of List in a string.format? -



c# - How do I display all contents of List<DayOfWeek> in a string.format? -

this little application different restaurants , days of week open. in interface, have check boxes each of days of week. want output in string.format each of selected days(check) boxes. possible? here code grabs checkboxes:

foreach (checkbox cb in grpdaysopen.controls) // add together days of week restaurant open { dayofweek enumconvertedsuccessfully; // contain enums if (cb.checked && enum.tryparse<dayofweek>(cb.text, out enumconvertedsuccessfully)) favoritediningplace.opendays.add(enumconvertedsuccessfully); }

here current override tostring:

return string.format( "{0} chian of {1} seating capacity of {2}:\r\nsmoking {3}. lastly month's sales {4}, while lastly months costs {5}. \r\nthe restaurant open {6}", this.name, this.chain, this.seatingcapacity, this.smoking, this.lastmonthsales, this.lastmonthcosts, this.opendays);

i don't know if need include other code this. if need clarification, allow me know. above tostring outputs

"system.collections.generic.list`[system.dayofweek]"

for this.opendays.

list<dayofweek> d = new list<dayofweek> { dayofweek.monday, dayofweek.saturday }; string res = string.join(", ", d);

c# enums tostring

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -