CSharp examples for Language Basics:var
Use var to create object and access its member
using static System.Console; using System;/*from www .j a v a 2 s . co m*/ using System.Collections.Generic; using System.Text.RegularExpressions; class Program { static void Main(string[] args) { var t = new Thing(); t.Data = 42; WriteLine($"Thing: {t.Process("42")}"); } } public class Thing { public object Data; public string Process(string input) { if (Data == input) { return Data.ToString() + Data.ToString(); } else { return Data.ToString(); } } }