Change color of expressions that starts with '#' - c#

I need to create a winform to color expressions that starts with '#' that the user wrote in a textbox (can be a richTextBox or some Infragistics tool, does't really matter, it just have to work).
Exemple:
nothing #expression nothingelse
the #expression must be colored
I've tried to split the string from the textbox by the spaces to identify the word, but I wasn't abble to replace it correctly. Now I'm learning about Regex and trying to apply it to my problem.
I'm using C# in Visual Studio Community 2017.
EDIT
I changed a little the code from here, trying to fit it into my problem. But the limiter doesnt work as it is suppouse to. I belive that it is happening becouse that the selection starts in the '#', but there can be a space before that, so the code doesn't work.
Here is the code as I'm using it:
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
int current = richTextBox1.SelectionStart;
for (int i = 0; i < richTextBox1.Lines.Length; i++)
{
string line = richTextBox1.Lines[i];
int index = line.IndexOf(' '), lineFirstIndex = line.IndexOf('#');
if (index != -1 && lineFirstIndex != -1)
{
richTextBox1.Select(lineFirstIndex, index);
richTextBox1.SelectionColor = Color.Red;
}
else
{
lineFirstIndex = richTextBox1.GetFirstCharIndexFromLine(i);
richTextBox1.Select(lineFirstIndex, line.Length);
richTextBox1.SelectionColor = Color.Empty;
}
}
richTextBox1.Select(current, 0);
}

You need to use Regex like this :
foreach (string result in Regex.Split(TextBox1, #" #\w+"))
{
//do stuff...
}

I got the result that I wished, but there is a little problem. If i erase something with BackSpace, the backcolor starts to highlight everything.
I belive that this is something of the SelectionBackColor propriety, becouse it doesn't happend when I'm using SelectionColor.
The code:
private void FindAt() //acha arrobas
{
for(int r = 0; r <= tam; r++)
{
for(int z = 0; z < (tam - r); z++)
{
if (z > 8) break;
String temp = text.Substring(r, z);
char aux = '\0';
if (lista.FindStringExact(temp) != -1)
{
if (tam > r + z) aux = text.ElementAt(r + z);
if ((r > 0 && text.ElementAt(r - 1) == '#') && aux == ' ')
{
atIndex[0, ctrlAt] = r-1; //salva posição inicial da variavel, incluindo o # (por isso o -1)
atIndex[1, ctrlAt] = z + 1; //salva comprimento da variavel, + 1 por causa do # (segundo argumento da substring)
ctrlAt++;
}
}
}
}
}
and the function to color the substring:
private void ColorAt() //colore variaveis
{
for (int a = 0; a < ctrlAt; a++)
{
if (atIndex[0, a] != -1)
{
richTextBox1.Select(atIndex[0, a], atIndex[1, a]);
richTextBox1.SelectionBackColor = Color.Green;
}
else richTextBox1.SelectionBackColor = Color.Empty;
}
}

Related

How to highliht specific word in richtextbox during writing?

Basically I want to make an autocorrect for my language. I have a RichTextBox(name: MainText), where I write. during writing, the program should every word if it exists in a dictionary file. if not then change the specific word color to red.
It has a timer. after every second it gets the written text and puts the words to an str array, and reads correct words from dictionary.txt file and puts them in a list. during comparison of the strings, it never highlights the incorrect words and it has always indexOutOfRange errors. How to fix it?
Here is the timer tick void:
void CheckTimer_Tick(object sender, EventArgs e)
{
List<string> correct_words = File.ReadAllLines(DictPath).ToList();
string text = MainText.Text;
string[] Words = text.Split(' ', '.');
for (int i = 0; i < Words.Length; i++)
{
if (correct_words.Contains(Words[i])) { }
else
{
int index = 0;
String temp = MainText.Text;
MainText.Text = "";
MainText.Text = temp;
while (index < MainText.Text.LastIndexOf(Words[i]))
{
MainText.Find(Words[i], index, MainText.TextLength, RichTextBoxFinds.None);
MainText.SelectionColor = Color.Red;
index = MainText.Text.IndexOf(Words[i], index) + 1;
}
}
}
}
I also tried this void:
void HighlightPhrase(RichTextBox box, string phrase, Color color)
{
int pos = box.SelectionStart;
string s = box.Text;
for (int ix = 0; ;)
{
int jx = s.IndexOf(phrase, ix, StringComparison.CurrentCultureIgnoreCase);
if (jx < 0) break;
box.SelectionStart = jx;
box.SelectionLength = phrase.Length;
box.SelectionColor = color;
ix = jx + 1;
}
box.SelectionStart = pos;
box.SelectionLength = 0;
box.ForeColor = Color.Black;
}
This worked if I gave it a specific string, but it couldn't recognize the phrase input from the dictionary and gave the indexOutOfRange error.
public Form1()
{
InitializeComponent();
}
private void textbox1_TextChanging(object sender, EventArgs e)
{
string[] words = textBox1.Text.Split(',');
foreach(string word in words)
{
int startindex = 0;
while(startindex < richTextBox1.TextLength)
{
int wordstartIndex = richTextBox1.Find(word, startindex, RichTextBoxFinds.None);
if (wordstartIndex != -1)
{
richTextBox1.SelectionStart = wordstartIndex;
richTextBox1.SelectionLength = word.Length;
richTextBox1.SelectionBackColor = Color.Yellow;
}
else
break;
startindex += wordstartIndex + word.Length;
}
}
}
For Clear Hightlight Use This Code
richTextBox1.SelectionStart = 0;
richTextBox1.SelectAll();
richTextBox1.SelectionBackColor = Color.White;

Trouble creating algorithm that modifies elements of a 2d array

I am having trouble editing the values of a 2d char array.
char[,] chrRaster = new char[4, 5];
After adding values to the array and printing it to the console, I get:
// Input example:
*****
**.**
*****
****.
I am trying to make an algorithm that replaces every '*' that is beside, under or above a '.' by a '.' and then printing this to the console.
// Output after algorithm example:
**.**
*...*
**.*.
***..
I have tried converting the 2d char array to a 2d string array and then using IndexOf('*') to replace every '*' that is beside, under or above a '.', and I also tried calculating this using a number of if and for loops without any luck.
static void Main(string[] args)
{
// Variablen
int intTestgeval = 0; // Number of times you want program to repeat
int intN = 0; // Number of rows
int intM = 0; // Number of coloms
char chrGrond; // Used to store '*' or '.'
char[,] chrRaster; // 2d char array used to store all values
// Code
try
{
intTestgeval = Int32.Parse(Console.ReadLine()); // Number of times program will repeat
if(intTestgeval > 150) // Program can not repeat more then 150 times
{
throw new Exception();
}
}
catch (Exception)
{
Environment.Exit(0);
}
intN = Controle(intN); // Number of rows ophalen
intM = Controle(intM); // Number of Coloms ophalen
chrRaster = new char[intN, intM]; // Initializing array with user input
for (int intR = 0; intR < intTestgeval; intR++) // Print 2d array to console
{
for(int intY = 0; intY < intN; intY++)
{
for(int intZ = 0; intZ < intM; intZ++)
{
chrGrond = Convert.ToChar(Console.ReadKey().KeyChar);
chrRaster[intY, intZ] = chrGrond;
}
Console.WriteLine();
}
instorten[intR] = Instorten(chrRaster, intN, intM); // Ignore this part, that's another part of my assignment not related to my question.
}
}
static int Controle( int intX )
{
try
{
intX = Int32.Parse(Console.ReadLine());
if (intX > 150 || intX < 1) // Length of row and colom can not exceed 20 and can not go lower then 1
{
throw new Exception();
}
return intX;
}
catch // Program will off if value does not meet requirements
{
Environment.Exit(0);
return intX;
}
}
// It is this part of the program I need help with. This is what I tried but can't get any further
static int Instorten(char[,] chrRaster, int intN, int intM)
{
for (int intY = 0; intY < intN; intY++)
{
for (int intZ = 0; intZ < intM; intZ++)
{
if(chrRaster[intY, intZ] == '.' && chrRaster[intY, intZ + 1] == '*' || chrRaster[intY, intZ] == '*' && chrRaster[intY, intZ + 1] == '.')
{
}
}
Console.WriteLine();
}
int intm = 0;
return intm;
}
}
One way to do this would be to make a copy of the array and then iterate over it, examining each item. If the item is a '.', then update the neighbors of this item in the original array.
To determine the neighbors, we simply add one to the row to get the neighbor below, subtract one from the row to get the neighbor above, and similarly we can get the right and left neighbors by adding/subtracting from the column value. Of course we need to ensure that we're inside the bounds of the array before doing anything.
We could write a method with this logic that might look like:
private static void ExposeDotNeighbors(char[,] input)
{
if (input == null) return;
// Make a copy of the input array that we can iterate over
// so that we don't analyze items that we've already changed
var copy = (char[,]) input.Clone();
for (var row = 0; row <= copy.GetUpperBound(0); row++)
{
for (var col = 0; col <= copy.GetUpperBound(1); col++)
{
if (copy[row, col] == '.')
{
// Update neighbors in original array
// Above = [row - 1, col], Below = [row + 1, col],
// Left = [row, col - 1], Right = [row, col + 1]
// Before updating, make sure we're inside the array bounds
if (row > 0) input[row - 1, col] = '.';
if (row < input.GetUpperBound(0)) input[row + 1, col] = '.';
if (col > 0) input[row, col - 1] = '.';
if (col < input.GetUpperBound(1)) input[row, col + 1] = '.';
}
}
}
}
We can also write some helper methods that will give us the initial array and to print an array to the console (also one that will write a header to the console):
private static char[,] GetInitialArray()
{
var initialArray = new char[4, 5];
for (var row = 0; row <= initialArray.GetUpperBound(0); row++)
{
for (var col = 0; col <= initialArray.GetUpperBound(1); col++)
{
if ((row == 1 && col == 2) || (row == 3 && col == 4))
{
initialArray[row, col] = '.';
}
else
{
initialArray[row, col] = '*';
}
}
}
return initialArray;
}
private static void PrintArrayToConsole(char[,] input)
{
if (input == null) return;
for (var row = 0; row <= input.GetUpperBound(0); row++)
{
for (var col = 0; col <= input.GetUpperBound(1); col++)
{
Console.Write(input[row, col]);
}
Console.WriteLine();
}
}
private static void WriteHeader(string headerText)
{
if (string.IsNullOrEmpty(headerText))
{
Console.Write(new string('═', Console.WindowWidth));
return;
}
Console.WriteLine('╔' + new string('═', headerText.Length + 2) + '╗');
Console.WriteLine($"║ {headerText} ║");
Console.WriteLine('╚' + new string('═', headerText.Length + 2) + '╝');
}
With these helper methods, we can then write code like:
private static void Main()
{
var chrRaster = GetInitialArray();
WriteHeader("Before");
PrintArrayToConsole(chrRaster);
ExposeDotNeighbors(chrRaster);
WriteHeader("After");
PrintArrayToConsole(chrRaster);
GetKeyFromUser("\nDone! Press any key to exit...");
}
And out output would look like:
I noticed that you also appear to be getting the values from the user, and using try/catch blocks to validate the input. A better approach might be to write a helper method that takes in a string that represents the "prompt" to the user, and a validation method that can be used to validate the input. With this, we can keep asking the user for input until they enter something valid.
Below are methods that get an integer and a character from the user, and allow the caller to pass in a function that can be used for validation. These methods will not return until the user enters valid input:
private static char GetCharFromUser(string prompt, Func<char, bool> validator = null)
{
char result;
var cursorTop = Console.CursorTop;
do
{
ClearSpecificLineAndWrite(cursorTop, prompt);
result = Console.ReadKey().KeyChar;
} while (!(validator?.Invoke(result) ?? true));
Console.WriteLine();
return result;
}
private static int GetIntFromUser(string prompt, Func<int, bool> validator = null)
{
int result;
var cursorTop = Console.CursorTop;
do
{
ClearSpecificLineAndWrite(cursorTop, prompt);
} while (!int.TryParse(Console.ReadLine(), out result) ||
!(validator?.Invoke(result) ?? true));
return result;
}
private static void ClearSpecificLineAndWrite(int cursorTop, string message)
{
Console.SetCursorPosition(0, cursorTop);
Console.Write(new string(' ', Console.WindowWidth));
Console.SetCursorPosition(0, cursorTop);
Console.Write(message);
}
We can then re-write our GetInitialArray method to use these methods to get the dimensions and values from the user:
private static char[,] GetInitialArray()
{
const int maxCols = 20;
const int maxRows = 20;
var numCols = GetIntFromUser(
$"How many columns do you want (1 - {maxCols}): ",
i => i > 0 && i <= maxCols);
var numRows = GetIntFromUser(
$"How many rows do you want (1 - {maxRows}): ",
i => i > 0 && i <= maxRows);
var initialArray = new char[numRows, numCols];
for (var row = 0; row <= initialArray.GetUpperBound(0); row++)
{
for (var col = 0; col <= initialArray.GetUpperBound(1); col++)
{
initialArray[row, col] = GetCharFromUser(
$"Enter value for [{row}, {col}] ('.' or '*'): ",
c => c == '.' || c == '*');
}
}
return initialArray;
}
And now our output might look like this:
If you try it, notice that you cannot enter an illegal value. The program just waits for you to read the instructions and enter a valid number or character. :)
Here is the algorithm that does what you want. I have tried to explain my code in the comments. The output will match what you're looking for.
static void Main(string[] args)
{
char STAR = '*';
char DOT = '.';
var input = new char[,]
{
{ STAR,STAR,STAR,STAR,STAR},
{ STAR,STAR,DOT,STAR,STAR},
{ STAR,STAR,STAR,STAR,STAR},
{ STAR,STAR,STAR,STAR,DOT}
};
var output = new char[4, 5];
// Copy each from input to output, checking if it touches a '.'
for (int x = 0; x < 4; x++)
{
for (int y = 0; y < 5; y ++)
{
if (input[x, y] == STAR)
{
var isDot = false;
// Check left
if (x > 0)
isDot = input[x - 1, y] == DOT;
// Check right
if (x < 3)
isDot = isDot || (input[x + 1, y] == DOT);
// Check above
if (y > 0)
isDot = isDot || (input[x, y - 1] == DOT);
// Check below
if (y < 4)
isDot = isDot || (input[x, y + 1]) == DOT;
output[x, y] = isDot ? DOT : STAR;
}
else
{
output[x, y] = input[x, y];
}
}
}
// Print output
for (int x = 0; x < 4; x ++)
{
for (int y = 0; y < 5; y ++)
{
Console.Write(output[x, y]);
}
Console.WriteLine();
}
Console.Read();
}
You can go like this :
using System;
public class chars
{
public static void Main(string[] args)
{
char[,] charArray = new char[,] {{'*','*','*','*','*'},
{'*','*','.','*','*'},
{'*','*','*','*','*'},
{'*','*','*','*','.'}};
int[,] holdIndex = new int[4, 5];
for(int i = 0; i<4; i++) // get allindexes containing '.'
{
for(int j = 0; j<5; j++)
{
if(charArray[i,j] == '.')
holdIndex[i,j] = 1;
else
holdIndex[i,j] = 0;
}
}
for(int i = 0; i<4; i++)
{
for(int j = 0; j<5; j++)
{
if(holdIndex[i,j] == 1)
{
if(i!=0)
charArray[i-1,j] = '.'; //up
if(j!=0)
charArray[i,j-1] = '.'; // left
if(j!=4)
charArray[i,j+1] = '.'; //right
if(i!=3)
charArray[i+1,j] = '.'; //down
}
}
}
for(int i = 0; i<4; i++)
{
for(int j = 0; j<5; j++)
{
Console.Write(charArray[i,j]);
}
Console.WriteLine();
}
Console.Read();
}
}

Failing to convert TextBox_TextChanged() in C++ To C#

I was working on C++ with Juce Library for few months. I had written a code in my project where the formatting of textbox was modified to only hexadecimal values with few features:
Demonstratation:
12 ab 32 a5 64
Now if my cursor is at the end and i go on pressing backspace, it shud remove the values as it happens in a general text box.
Now If my cursor is at the beginning of a5, and i press "delete key", the value should become like:
12 ab 32 56 4
If my cursor is at the end of a5 and i press the 'delete key" nothing should happen. while entering the values space bar should not let spacing bw two values. Only a-f and 0-9 should be allowed to enter.
Code in C++ here:
void CMSP430CommPanel::textEditorTextChanged (TextEditor& editor)
{
if(&editor == m_texti2cWrite)
{
int count = 0;
int location;
String text1 = m_texti2cWrite->getText();
String text = m_texti2cWrite->getText().removeCharacters(" ");
String hexString = String::empty;
int countCaret = m_texti2cWrite->getCaretPosition();
for(int i=0; i < text.length(); i++)
{
hexString = hexString + String (&text[i], 1);
if((i+1) % 2 == 0)
{
if(i != text.length()-1)
{
hexString = hexString + T(" ");
count ++;
}
}
count ++;
}
m_texti2cWrite->setText(hexString,false);
if(text1.length() == m_texti2cWrite->getCaretPosition())
{
m_texti2cWrite->setCaretPosition(count);
}
else
{
m_texti2cWrite->setCaretPosition(countCaret);
}
}
}
I want the same thing to work in my WPF application. Lets say the general implementation of the same code in C#.
please help!!!
Try this (TextChanged-Event of your TextBox):
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox m_texti2cWrite = (TextBox)sender;
int count = 0;
string text1 = m_texti2cWrite.Text;
string text = m_texti2cWrite.Text.Replace(" ", string.Empty);
string hexString = string.Empty;
int countCaret = e.Changes.ToList()[0].Offset;
for (int i = 0; i < text.Length; i++)
{
hexString += text[i];
if ((i + 1) % 2 == 0)
{
if (i != text.Length - 1)
{
hexString = hexString + " ";
count++;
}
}
count++;
}
m_texti2cWrite.Text = hexString;
if (text1.Length == countCaret)
{
m_texti2cWrite.Select(count, 0);
}
else
{
if (e.Changes.ToList()[0].RemovedLength == 0)
{
m_texti2cWrite.Select(countCaret + 1, 0);
if (string.IsNullOrWhiteSpace(hexString.Substring(countCaret, 1)))
m_texti2cWrite.Select(countCaret + 2, 0);
}
else
{
m_texti2cWrite.Select(countCaret, 0);
if (string.IsNullOrWhiteSpace(hexString.Substring(countCaret, 1)))
m_texti2cWrite.Select(countCaret + 1, 0);
}
}
}
}
EDIT (only accept Digits, ControlKeys or a-f):
Add this method:
private Boolean IsTextAllowed(String text)
{
string acceptedChars = "ABCDEFabcdef";
foreach (Char c in text.ToCharArray())
{
if (Char.IsDigit(c) || Char.IsControl(c) || acceptedChars.Contains(c)) continue;
else return false;
}
return true;
}
Add the TextBox_PreviewTextInput-Event to your TextBox
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text);
}
public class CMSP430CommPanel
{
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found:
public void textEditorTextChanged(TextEditor editor)
{
if (editor == m_texti2cWrite)
{
int count = 0;
int location;
string text1 = m_texti2cWrite.getText();
string text = m_texti2cWrite.getText().removeCharacters(" ");
string hexString = string.empty;
int countCaret = m_texti2cWrite.getCaretPosition();
for (int i = 0; i < text.Length; i++)
{
hexString = hexString + (string)(text[i], 1);
if ((i + 1) % 2 == 0)
{
if (i != text.Length - 1)
{
hexString = hexString + T(" ");
count++;
}
}
count++;
}
m_texti2cWrite.setText(hexString,false);
if (text1.Length == m_texti2cWrite.getCaretPosition())
{
m_texti2cWrite.setCaretPosition(count);
}
else
{
m_texti2cWrite.setCaretPosition(countCaret);
}
}
}
}

Highlighting strings in richtextBox

I need to highlight all words in richtextBox that are listed in .xls file, here's a part of my code:
public void HighlightWords(RichTextBox rtb1, DataTable dtXLS)
{
for (int i = 0; i < dtXLS.Rows.Count; i++)
{
string[] wordsToRedact = new string[dtXLS.Rows.Count];
wordsToRedact[i] = dtXLS.Rows[i][0].ToString();
Regex test = new Regex(#"[\p{P}|\s](" + wordsToRedact[i] + #")[\p{P}|\s]", RegexOptions.Singleline | RegexOptions.Compiled);
MatchCollection matchlist = test.Matches(rtb1.Text);
if (matchlist.Count > 0)
{
for (int j = 0; j < matchlist.Count; j++)
{
WordsToRedact words = new WordsToRedact(matchlist[j]);
HighLighting highLight = new HighLighting();
highLight.Highlight_Words(rtb1, words);
}
}
}
}
class HighLighting
{
public void Highlight_Words(RichTextBox rtb, WordsToRedact e)
{
rtb.SelectionBackColor = Color.LightSkyBlue;
rtb.SelectionStart = e.index;
rtb.SelectionLength = e.length;
rtb.ScrollToCaret();
}
}
class WordsToRedact
{
public int index;
public int length;
public string value;
public WordsToRedact(Match m)
{
this.index = m.Groups[1].Index;
this.length = m.Groups[1].Length;
this.value = m.Groups[1].Value;
}
}
The problem is, it didn't highlight some of the words that also matches the regex. Some are highlighted but some are not. Accuracy is my problem, and I don't know where I am getting wrong.
I checked your code, there were some problems in it, i list them below :
first :
for (int i = 0; i < dtXLS.Rows.Count; i++)
{
string[] wordsToRedact = new string[dtXLS.Rows.Count];
...
is wrong, you should initialize your string array before the for loop otherwise it gets renewed in each loop iteration, do this :
string[] wordsToRedact = new string[listBox1.Items.Count];
for (int i = 0; i < dtXLS.Rows.Count; i++)
{
...
second : (your major problem)
you should color the selected part after it is selected not before, that is why your code does not select the last match, you should do this :
rtb.SelectionStart = e.index;
rtb.SelectionLength = e.length;
rtb.SelectionBackColor = Color.LightSkyBlue;
and Last : (with doubt)
I think but I am not sure that you should use index zero [0] not [1]
public WordsToRedact(Match m)
{
this.index = m.Groups[0].Index;
this.length = m.Groups[0].Length;
this.value = m.Groups[0].Value;
}
This will work:
Regex test = new Regex(#"\b(" + wordsToRedact[i] + #")\b",
RegexOptions.Singleline | RegexOptions.Compiled);
mahdi-tahsildari's answer did answer my problem! But in addition with his answer I want also to post the other option that I've tried that also fixed the issue.
I changed the HighLighting class to this codes:
class HighLighting
{
public void HighlightText(RichTextBox rtb, string word)
{
int s_start = rtb.SelectionStart, startIndex = 0, index;
while ((index = rtb.Text.IndexOf(word, startIndex)) != -1)
{
rtb.Select(index, word.Length);
rtb.SelectionBackColor = Color.Yellow;
startIndex = index + word.Length;
}
rtb.SelectionStart = s_start;
rtb.SelectionLength = 0;
rtb.SelectionColor = Color.Black;
rtb.ScrollToCaret();
}
}
and everything goes fine. this code and mahdi-tahsildari's answer did the same thing! Thanks for all your help! :))

highlight the '#' until line end in richtextbox

I have the following text in my RIchTextBox:
foo:baa#done baa
a:b#pending ee
and I want highlight all after # and before " "(espace)
How I do this? I tried make the end as IndexOf of \t or " " but it returns -1.
My code(not working as expected):
string[] lines = list.Lines;
string line;
for (int i = 0, max = lines.Length; i < max; i++)
{
line = lines[i];
int start = list.Find("#");
int end = ??? // I tried list.Find("\t") and list.Find(" ")
if (-1 != start || -1 != end)
{
list.Select(start, end);
list.SelectionColor = color;
}
}
list is an RichTextBox
Use GetLineFromCharIndex() to get the line number of the Find() method return value. Then GetFirstCharIndexFromLine(line + 1) to know where the next line starts. That gives you the SelectionStart and SelectionLength values you need to highlight the text.
try this:
string[] lines = list.Lines;
string line;
int len = 0;
for (int i = 0, max = lines.Length; i < max; i++)
{
line = lines[i];
int j = i == 0 ? 0 : len;
string str = Regex.Match(line, #"#.*$").Value;
if (!string.IsNullOrEmpty(str))
{
int start = list.Find(str, j, RichTextBoxFinds.None);
if (start != -1)
{
list.Select(start, str.Length);
list.SelectionColor = Color.Red;
}
len += line.Length;
}
}
Maybe you should use line.IndexOf instead of list.Find?
In short, you seem to be searching for characters in your List control, not in the string line.

Categories

Resources