|
عشق من سی شارپ عشق من سی شارپ
|
Easy writing all text to a file WriteAllText will create the file if it doesn't exist, otherwise overwrites it. It will also close the file. using System; namespace PlayingAround { class ReadAll { public static void Main(string[] args) { string myText = "Line1" + Environment.NewLine + "Line2" + Environment.NewLine; System.IO.File.WriteAllText(@"C:\t2", myText); } } } [ چهارشنبه چهارم اسفند 1389 ] [ 20:14 ] [ علی احمدی ]
[ ]
Read a file line by line with no error checking Useful if the file may be really large. StreamReader sr = new StreamReader("fileName.txt"); string line; while((line= sr.ReadLine()) != null) { Console.WriteLine("xml template:"+line); } if (sr != null)sr.Close(); //should be in a "finally" or "using" block [ چهارشنبه چهارم اسفند 1389 ] [ 20:13 ] [ علی احمدی ]
[ ]
Read all the lines from a file into an array using System; namespace PlayingAround { class ReadAll { public static void Main(string[] args) { string[] lines = System.IO.File.ReadAllLines(@"C:\t1"); Console.Out.WriteLine("contents = " + lines.Length); Console.In.ReadLine(); } } } [ چهارشنبه چهارم اسفند 1389 ] [ 20:13 ] [ علی احمدی ]
[ ]
Read a file with a single call to sReader.ReadToEnd() using streams public static string getFileAsString(string fileName) { StreamReader sReader = null; string contents = null; try { FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); sReader = new StreamReader(fileStream); contents = sReader.ReadToEnd(); } finally { if(sReader != null) { sReader.Close(); } } return contents; } [ چهارشنبه چهارم اسفند 1389 ] [ 20:13 ] [ علی احمدی ]
[ ]
Read an entire file into a string using System; namespace PlayingAround { class ReadAll { public static void Main(string[] args) { string contents = System.IO.File.ReadAllText(@"C:\t1"); Console.Out.WriteLine("contents = " + contents); } } } [ چهارشنبه چهارم اسفند 1389 ] [ 20:13 ] [ علی احمدی ]
[ ]
The obligatory example for any language, Raw CSharp compiler You can compile c# using the command line version and then run the new program by entering
HelloWorld You can get Nant, a build tool like the old 'make', from http://sourceforge.net/projects/nant. Reference By http://www.fincher.org/tips/Languages/csharp.shtml [ چهارشنبه چهارم اسفند 1389 ] [ 20:5 ] [ علی احمدی ]
[ ]
Ebteda bayad shoma yek List as Data Sort shode dashteh bashin masalan [ یکشنبه نوزدهم خرداد 1387 ] [ 19:9 ] [ علی احمدی ]
[ ]
ادامه مطلب [ شنبه چهارم خرداد 1387 ] [ 15:3 ] [ علی احمدی ]
[ ]
سلام دوستان این هم کد یه برنامه بانک البته کامل نیست #include "graphics.h" ادامه مطلب [ یکشنبه پانزدهم مهر 1386 ] [ 15:6 ] [ علی احمدی ]
[ ]
این هم سایتهای جالب سی شارپ: http://www.csharp-station.com/ [ جمعه سیزدهم بهمن 1385 ] [ 19:57 ] [ علی احمدی ]
[ ]
|
|
| [ طراحی : Cshart Group ] [ WebSite Design By : Cshart Group] |