-
+144
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
static void Main(string[] args)
{
int[,] mas = new int[5, 5];
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
mas[i, j] = rnd.Next(0, 100);
Console.Write(mas[i, j] + "\t");
}
Console.WriteLine();
}
}
Ebaw,
10 Августа 2010
-
+111
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
string filename = "pasker_ltd.xls";
string ConnectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}; Extended Properties=Excel 8.0;", filename);
DataSet ds = new DataSet("EXCEL");
OleDbConnection cn = new OleDbConnection(ConnectionString);
cn.Open();
DataTable schemaTable =cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[] { null, null, null, "TABLE" });
string sheet1 = (string)schemaTable.Rows[0].ItemArray[2];
string select = String.Format("SELECT * FROM [{0}]", sheet1);
OleDbDataAdapter ad = new OleDbDataAdapter(select, cn);
ad.Fill(ds);
DataTable tb = ds.Tables[0];
dataGridView1.DataSource = tb;
Ebaw,
10 Августа 2010
-
+104
- 1
- 2
- 3
- 4
- 5
int x = 1, z = ++x + x;
Console.WriteLine (x.ToString () + " " + z.ToString ());
x = 1;
int z1 = x + ++x;
Console.WriteLine (x.ToString () + " " + z1.ToString ());
Вот такой код
Ebaw,
10 Августа 2010
-
+117
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
using System;
class PleaseSayUra
{
static void WriteHelloSam()
{
Console.WriteLine("Hellosam");
WriteHelloSam();
}
}
>>Пытаюсь вызвать метод, а программа пишет ошибка "Не содержит статического метода "Main", подходящего для точки входа ConsoleApplication1" Рассажите что такое?
http://otvet.mail.ru/question/43958756/
This is obvious,
10 Августа 2010
-
+144
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
public static List<string> GetWords(string text, out List<int> index)
{
MatchCollection matches = Regex.Matches(text, @"[\w.]+|[\W]+");
List<string> m = new List<string>();
index = new List<int>();
foreach (Match match in matches)
{
if (match.Value.IndexOf('.', match.Value.Length - 1) != -1 && !isPart(match.Value) && match.Value.Length > 1)
{
string str = match.Value.Remove(match.Value.Length - 1, 1);
m.Add(str);
m.Add(".");
}
else
{
m.Add(match.Value);
index.Add(match.Index);
}
}
return m;
}
Нужно подать текст, который будет разбит на <Word> ... </Word>. При этом нужно отслеживать сокращения типа "г.", "т.д.", "др" и т.д. Но возникает проблема, слова типа "привет." будут также рассматриваться как единое целое, поэтому приходиться проверять, сокращение это или нет в строках 8-13, если есть другой (оптимальный) способ, то был бы благодарен )
Attila,
10 Августа 2010
-
+114
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
static void Main(string[] args)
{
metka:
int exit = 0;
Console.Clear();
TextRead ob1 = new TextRead();
Meneger ob2 = new Meneger();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" " + "ДОБРО ПОЖАЛОВАТЬ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("--------------------------------------------------------------------------------");
Thread.Sleep(500);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Выберите нужную программу:");
Thread.Sleep(500);
Console.WriteLine();
string vib;
Console.WriteLine("1)Текстовый редактор");
Thread.Sleep(500);
Console.WriteLine("2)Файловый менеджер");
Console.WriteLine("3)Выход");
vib = Console.ReadLine();
switch (vib)
{
case "1" : ob1.read();
break;
case "2": ob2.med();
break;
case "3": exit = 1;
break;
default: Console.WriteLine("Выберите 1 или 2 ");
break;
}
if (exit == 0)
{
goto metka;
}
}
Имитация загрузки
Thread.Sleep(500);хВВDDDD
Nigma143,
08 Августа 2010
-
+115
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
public void F2()
{
Console.Clear();
try
{
Console.Write("Введите имя файла для добавления данных:");
string str1 = Console.ReadLine();
try
{
FileStream dd = new FileStream("C:\\" + str1 + ".txt", FileMode.Open);
dd.Close();
}
catch
{
Console.WriteLine(" Файл с таким именем не существует ");
Console.WriteLine(" Будет создан новый файл");
Console.WriteLine();
Console.WriteLine(" Нажмите Enter для продолжения");
Console.ReadLine();
}
Console.Clear();
FileStream f = new FileStream("C:\\" + str1 + ".txt", FileMode.Append);
StreamWriter zapis = new StreamWriter(f);
Console.WriteLine("вводите текст , 'стоп' для завершения");
string s;
do
{
Console.Write(": ");
s = Console.ReadLine();
if (s != "стоп")
{
s = s + "\r\n";
zapis.Write(s);
}
}
while (s != "стоп");
zapis.Close();
f.Close();
Console.WriteLine("Файл успешно добавлен");
}
catch
{
Console.WriteLine("error");
}
}
Проверка на существования файла
Nigma143,
08 Августа 2010
-
+114
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
Console.Clear();
try
{
Console.Write("Введите имя нового файла:");
string str1 = Console.ReadLine();
FileStream f = new FileStream("C:\\" + str1 + ".txt", FileMode.Create);
StreamWriter zapis = new StreamWriter(f);
Console.WriteLine("вводите текст , 'стоп' для завершения");
string s;
do
{
Console.Write(": ");
s = Console.ReadLine();
if (s != "стоп")
{
s = s + "\r\n";
zapis.Write(s);
}
}
while (s != "стоп");
zapis.Close();
f.Close();
Console.WriteLine("Файл успешно запишен");
}
catch
{
Console.WriteLine("error");
}
Школота атакЭ
"запишен"хD
Nigma143,
08 Августа 2010
-
+124
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
public void GeneratXMLForChatServerControl()
{
List<ClassUsersList> List = GetUsersList();
System.IO.StreamWriter TextW = new System.IO.StreamWriter("Update_Settings.xml", false,System.Text.Encoding.GetEncoding("UTF-8"));
TextW.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
TextW.WriteLine("<General>");
foreach (ClassUsersList User in List)
{
User.Information = User.Information.Replace("<", "");
User.Information = User.Information.Replace(">", "");
User.Information = User.Information.Replace("&", "");
TextW.WriteLine("<Name>" + User.Information + "</Name>");
TextW.WriteLine("<Login>" + User.UIN + "</Login>");
TextW.WriteLine("<Password>" + User.Pwd + "</Password>");
TextW.WriteLine("<LocalPath>D:\\chat2\\" + User.UID + "\\</LocalPath>");
TextW.WriteLine("<UID>" + User.UID + "</UID>");
TextW.WriteLine("<UIN>" + User.UIN + "</UIN>");
TextW.WriteLine("<Lock>0</Lock>");
TextW.WriteLine("");
}
TextW.WriteLine("</General>");
TextW.Flush();
TextW.Close();
}
Крутобл, создаём XML налету
Nigma143,
06 Августа 2010
-
+111
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
/// <summary>
/// Получает IPAdress к которому нужно подключиться
/// </summary>
private int Get_IPAdress_Server()
{
string Buf = "";
for (int i = 0; i < Server_IP.Servers_IP.Length; i++ )
{
try
{
TcpClient tc = new TcpClient(Server_IP.Servers_IP[i], Server_IP.Servers_Port[i]);
byte[] buffer = new byte[19];
NetworkStream nss = tc.GetStream();
nss.Read(buffer, 0, 19);
Buf = Encoding.ASCII.GetString(buffer).Trim();
Server_IPAdress = Buf.Substring(0, Buf.IndexOf(":"));
Server_Port = int.Parse(Buf.Substring(Buf.IndexOf(":") + 1, Buf.Length - Buf.IndexOf(":") - 1));
return 0;
}
catch (SocketException)
{
}
}
return -1;
}
Получаем индекс в коллекции где хранятся список серверов Первый доступный!
Nigma143,
06 Августа 2010