Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Why have I mark a string field as readonly in a immutable class if strings are immutable

$
0
0

I have an immutable class with only immutable properties. Strings are immutable so why I have to mark string field as readonly or use "init" in that class?

public class ImmutableType{    public readonly string LastName { get; }}

Viewing all articles
Browse latest Browse all 12111

Trending Articles



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