PDA

View Full Version : سوال: چطور ایندکس یک آرایه را بدست آوریم



alexmcse
چهارشنبه 28 آبان 1393, 18:19 عصر
سلام
من یک آرایه تعریف کردم و متن زیر که درون ریچ تکس است را در آن مقدار دهی کردم حالا می خواهم ایندکس سطر چهارم یا هر سطر دیگری را بدست بیاورم
چطور این کار را انجام بدهم؟


are small browser windows that appear on top of the website you're viewing. Although most are created by advertisers, they can also contain malicious or unsafe code. A pop-up blocker can prevent some or all of these windows from appearing.


The Pop-up Blocker feature in Internet Explorer is turned on by default. Another feature in Internet Explorer, SmartScreen Filter, also helps identify potentially malicious websites and known malware.
Periodically, Microsoft releases special security updates that can help protect your PC. These updates can help prevent viruses and other malware attacks by closing possible security holes.

foreach (var t in richTextBoxEx1.Lines ) {
line.Add( t.ToString() );
}

rasoolf
چهارشنبه 28 آبان 1393, 19:42 عصر
سلام
من یک آرایه تعریف کردم و متن زیر که درون ریچ تکس است را در آن مقدار دهی کردم حالا می خواهم ایندکس سطر چهارم یا هر سطر دیگری را بدست بیاورم
چطور این کار را انجام بدهم؟


are small browser windows that appear on top of the website you're viewing. Although most are created by advertisers, they can also contain malicious or unsafe code. A pop-up blocker can prevent some or all of these windows from appearing.


The Pop-up Blocker feature in Internet Explorer is turned on by default. Another feature in Internet Explorer, SmartScreen Filter, also helps identify potentially malicious websites and known malware.
Periodically, Microsoft releases special security updates that can help protect your PC. These updates can help prevent viruses and other malware attacks by closing possible security holes.

foreach (var t in richTextBoxEx1.Lines ) {
line.Add( t.ToString() );
}

برای چه کاری لازم دارید بگید شاید راه حل بهتری براش باشه.

rahnema1
چهارشنبه 28 آبان 1393, 20:12 عصر
سلام
به این صورت بنویسید
int index = Array.IndexOf(richTextBox1.Lines, "in Internet Explorer is");

alexmcse
چهارشنبه 28 آبان 1393, 23:14 عصر
برای چه کاری لازم دارید بگید شاید راه حل بهتری براش باشه.

سلام
میخواهم در اول هر سطر یک کارکتر ستاره بگذا رم باید اندیکس سطر را بدانم چطور ؟

ghossein
پنج شنبه 29 آبان 1393, 13:07 عصر
سلام
اضافه کردن کاراکتر ستاره به ابتدای هر سطر :

private void button1_Click(object sender, EventArgs e)
{

string[] lines = richTextBox1.Lines;

label1.Text = lines[0].ToString();
int i=0;
foreach (string line in lines)
{
lines[i] = "*" + line.ToString();
i++;
}

richTextBox1.Lines = lines;

}