private void button1_Click(object sender, EventArgs e)
{
string otext = textBox1.Text;
string ntext = string.Empty;
for (int i = 0; i < textBox1.Text.Length; i++)
{
int j = char.ConvertToUtf32(otext, i);
ntext += char.ConvertFromUtf32(255-j );
}
textBox1.Text = ntext;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text = textBox1.Text.Trim().ToLower()
.Replace("a", "ا").Replace("b", "ب").Replace("c", "ک").Replace("d", "د")
.Replace("e", "ا").Replace("f", "ف").Replace("g", "گ").Replace("h", "ه")
.Replace("i", "ی").Replace("j", "ج").Replace("k", "ک").Replace("l", "ل")
.Replace("m", "م").Replace("n", "ن").Replace("o", "و").Replace("p", "پ")
.Replace("q", "ک").Replace("r", "ر").Replace("s", "س").Replace("t", "ت")
.Replace("u", "ا").Replace("v", "و").Replace("w", "و").Replace("x", "")
.Replace("y", "ی").Replace("z", "ز");
}
using System.Text.RegularExpressions;
public static long LineCount2(string source, bool isFileName)
{
if (source != null)
{
string text = source;
long numOfLines = 0;
if (isFileName)
{
using (FileStream FS = new FileStream(source, FileMode.Open,
FileAccess.Read, FileShare.Read))
{
using (StreamReader SR = new StreamReader(FS))
{
while (text != null)
{
text = SR.ReadLine();
if (text != null)
{
++numOfLines;
}
}
}
}
return (numOfLines);
}
else
{
Regex RE = new Regex("\n", RegexOptions.Multiline);
MatchCollection theMatches = RE.Matches(text);
return (theMatches.Count + 1);
}
}
else
{
// Handle a null source here.
return (0);
}
}
private string GenerateRandomString(int size)
{
Random r = new Random();
string legalChars = "1234567890";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++)
sb.Append(legalChars.Substring(r.Next(0, legalChars.Length - 1), 1));
return sb.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(GenerateRandomString(6));
}
private long GenerateId3()
{
byte[] buffer = Guid.NewGuid().ToByteArray();
return BitConverter.ToInt64(buffer, 0);
}