Readonly Property : readonly « Class Interface « C# / C Sharp






Readonly Property

 
using System;

//VersionTest
public class VersionReporter {
    public static string version {
        get {
            return "2.0.0.0";
        }
    }

    public VersionReporter() {
    }
}


class VersionOutput {
    static void Main(string[] args) {
        string ver = VersionReporter.version;

        Console.WriteLine("Using version {0}", ver);
    }
}

 








Related examples in the same category

1.ReadOnly Fields
2.The use of readonly fieldsThe use of readonly fields
3.Demonstrate readonlyDemonstrate readonly