سلام بر برنامه نویسان عزیز ایران زمین 😉 در این مطلب کد خواندن decimal و رشته و کاراکتر با FileStream و StreamReader در #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی پروژه:
124.23
Test string
A
Test string
A
کد خواندن decimal و رشته و کاراکتر با FileStream و StreamReader در #C :
using System;
using System.IO;
using System.Text;
static class MainClass
{
static void Main()
{
// Create a new file.
using (FileStream fs = new FileStream("test.txt", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
// Write a decimal, string, and char.
w.WriteLine(124.23M);
w.WriteLine("Test string");
w.WriteLine('A');
}
}
// Open the file in read-only mode.
using System.IO;
using System.Text;
static class MainClass
{
static void Main()
{
// Create a new file.
using (FileStream fs = new FileStream("test.txt", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
// Write a decimal, string, and char.
w.WriteLine(124.23M);
w.WriteLine("Test string");
w.WriteLine('A');
}
}
// Open the file in read-only mode.