c# - Property or indexer 'System.DateTime.TimeOfDay' cannot be assigned to — it is read only -


i saw lots of duplicate post of me it's different.

i have datetime object , time portion & assign time that.when i'm going assign it raise error.

in here newstartdategroup datetime object in here opentime timespan

property or indexer cannot assigned — read only

else if(newstartdategroup.timeofday < i.opentime && newenddategroup.timeofday > i.closetime) // < >  {         newstartdategroup.timeofday = i.opentime; 

datetime struct in .net immutable, instead of changing it's values have create new one:

newstartdategroup = newstartdategroup.date.add(i.opentime); 

Comments

Popular posts from this blog

Using 'OR' and 'AND' in SQL Server -

c++ - NetBeans Remote Development with additional configuration -

visual studio - TFS will not accept changes I've made to a Java project -