string file_contents; using (StreamReader sr = new StreamReader("C:\\rpt.txt")) { file_contents = sr.ReadToEnd(); sr.Dispose(); }
DirectoryInfo[] dirs = new DirectoryInfo(@"c:\").GetDirectories(); using (StreamWriter sw = new StreamWriter("name_of_the_file")) { foreach (DirectoryInfo dir in dirs) { sw.WriteLine(dir.Name); } }
private string _first_name; public string First_Name { get {return _first_name;} set {_first_name = value;} }
set { variable_name = value; }
public class Project_Master { private string _project_name; public string Project_Name { get { return _project_name; } set { _project_name = value; } } }
private string _last_name = "Kumar"; public string Last_Name { get { return _last_name; } }
int area(int a, int b) { return a*b; --different number of parameters } int area(int b) { return a*a; } parameter return types int calc(int a) { return a; } double calc(double b) { return b*5; }
string str = "Vishal"; int length = str.Length;