Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Cannot assign to '<this>' because it is read-only in class

$
0
0

hi

i make a class that name is time interval in my code i wanna add to object together

public double tosec()
        {
            double s;
            s = (this.Days * 24 * 60 * 60) + (this.Hours * 60 * 60) + (this.Minuts * 60) + (this.Seconds);
            return s;
        }

public void addto(Timeinterval t)
        {
            double s1,s2,s3;
            s1 = this.tosec();
            s2 = t.tosec();
            s3 = s1 + s2;
            this = fromsec(s3);
        }

i cant use last line because it says  Cannot assign to '<this>' because it is read-only

thanks


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>