رمز : csharpamir.blogsky.com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using System.IO;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int ac = 1;
bool ok = true;
while (ok)
{
WriteLine("1 = Log in with the previous username ");
WriteLine("2 = Creating a username");
WriteLine("3 = delet file and acant");
WriteLine("4 = Change username and password");
if (ac == 1)
{
Write("");
ac++;
}
else
{
WriteLine("Enter (exit) to exit");
}
string n = ReadLine();
Clear();
switch (n)
{
case "1":
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "Log in with the previous username" + Environment.NewLine);
Clear();
WriteLine("enter nam");
string nam = ReadLine();
WriteLine("enter pasword");
string pasword = ReadLine();
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "nam:" + nam +Environment.NewLine+"paasword enter:" + pasword + Environment.NewLine);
if (File.Exists((nam + " acant" + ".txt")))
{
string content = File.ReadAllText((nam + " acant" + ".txt"));
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "paasword:" + content + Environment.NewLine);
if (content == pasword)
{
Clear();
WriteLine("enter");
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "enter" + Environment.NewLine);
var ta = Task.Run(async delegate
{
await Task.Delay(2000);
});
ta.Wait();
Clear();
if (File.Exists((nam + " file" + ".txt")))
{
string et = File.ReadAllText(nam + " file" + ".txt");
Console.WriteLine("Current content of file:");
Console.WriteLine(et);
WriteLine("_________________________________");
}
WriteLine("claer : enter claer \nexit = enter exit");
WriteLine("Please enter new content for the file:");
bool an = true;
while (an)
{
string newContent = Console.ReadLine();
if (newContent != "exit")
{
if (newContent != "claer")
{
File.AppendAllText((nam + " file" + ".txt"), newContent + Environment.NewLine);
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "enter file:" + newContent + Environment.NewLine);
}
else
{
File.WriteAllText((nam + " file" + ".txt"), Environment.NewLine);
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "enter file:" + newContent + Environment.NewLine);
WriteLine("clear");
var tabp = Task.Run(async delegate
{
await Task.Delay(2000);
});
tabp.Wait();
Clear();
}
}
else
{
Clear();
WriteLine("exit username");
var tabc = Task.Run(async delegate
{
await Task.Delay(2000);
});
tabc.Wait();
Clear();
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "exit" + Environment.NewLine);
an = false;
}
}
}
else
{
Clear();
WriteLine("not enter");
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "not enter" + Environment.NewLine);
var tabd = Task.Run(async delegate
{
await Task.Delay(2000);
});
tabd.Wait();
Clear();
}
}
else
{
Clear();
WriteLine("Username not found.");
var tabn = Task.Run(async delegate
{
await Task.Delay(2000);
});
tabn.Wait();
Clear();
}
break;
case "2":
Clear();
WriteLine("enter nam");
string nam1 = ReadLine();
WriteLine("enter pasword");
string pasword1 = ReadLine();
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "enter new acant" + Environment.NewLine + "nam:" + nam1 + "password" + pasword1);
File.WriteAllText((nam1 + " acant" + ".txt"), pasword1);
Clear();
WriteLine("A username with a password has been created for you");
var tab = Task.Run(async delegate
{
await Task.Delay(2000);
});
tab.Wait();
Clear();
break;
case "exit":
ok = false;
break;
case "3":
int ad = 1;
bool ok1 = true;
while (ok1)
{
if (ad == 2)
{
WriteLine("exit = enter exit");
}
ad++;
WriteLine("enter nam");
string nam2 = ReadLine();
if (nam2 == "exit")
{
break;
}
WriteLine("enter pasword");
string pasword2 = ReadLine();
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "enter delet acant" + Environment.NewLine + "nam:" + nam2 +Environment.NewLine + "password:" + pasword2);
if (File.Exists((nam2 + " acant" + ".txt")))
{
string content1 = File.ReadAllText((nam2 + " acant" + ".txt"));
if (content1 == pasword2)
{
WriteLine("1 = delet acant \n2 = delet file \nenter namber");
string af = ReadLine();
switch (af)
{
case "1":
File.Delete((nam2 + " acant" + ".txt"));
WriteLine("delet file");
break;
case "2":
string file_delet = File.ReadAllText((nam2 + " file" + ".txt"));
File.AppendAllText(("afrad vard.txt"), Environment.NewLine + "file dilet:" + Environment.NewLine + file_delet);
File.Delete(nam2 + " file" + ".txt");
break;
}
}
}
}
break;
case "4":
Write("enter nam:");
string nam_Change = ReadLine();
Write("enter pasword:");
string pasword_Change = ReadLine();
string content_Change = File.ReadAllText((nam_Change + " acant" + ".txt"));
Clear();
if(pasword_Change == content_Change)
{
Write("enter new nam:");
string new_nam = ReadLine();
Write("enter new password:");
string new_pasword = ReadLine();
if(new_nam != string.Empty)
{
File.Move(nam_Change + ".txt", new_nam + ".txt");
File.WriteAllText(new_nam + ".txt",new_pasword);
}
else
{
WriteLine("not enter nam");
}
}
else
{
WriteLine("not enter");
}
break;
}
}
}
}
}
Console.WriteLine("NAMBER 1");
double A = double.Parse(Console.ReadLine());
double b = double.Parse(Console.ReadLine());
//خط پایین عملیات توان را انجام می دهد
double p = Math.Pow(A, (int)b);
Console.WriteLine(p);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
bool cont = true;
while (cont)
{
Console.WriteLine("namber 1");
double namber1 = double.Parse(Console.ReadLine());
Console.WriteLine("amalkard");
string math = Console.ReadLine();
Console.WriteLine("namber 2");
double namber2 = double.Parse(Console.ReadLine());
double res;
//برای تبدیل دابل به استرینگ از خط زیرین استفاده می کنیم
//double namber1 = double.Parse(namber2);
switch (math)
{
case "+":
res = namber1 + namber2;
Console.WriteLine(res);
break;
case "-":
res = namber1 - namber2;
Console.WriteLine(res);
break;
case "*":
res = namber1 * namber2;
Console.WriteLine(res);
break;
case "/":
res = namber1 / namber2;
Console.WriteLine(res);
break;
}
// برای رفتن به خط بعد در رایت لاین با ید از بک اسلش ان استفاده کنیم
Console.WriteLine("Do you want to continue?");
string answer = Console.ReadLine();
if (answer == "no" || answer == "n" || answer == "No" || answer == "N" || answer == "NO")
cont = false;
}
}
}
}