Benutzer mit den meisten Antworten
Problem Hilfe

Frage
-
Hallo ich habe eine Suchfunktion in meine Studio Software eingebaut die einwandfrei läuft. das Problem:
Ich bekomme immer folgende Fehler Meldung " Warning CS0169 The field 'Form1.word' is never used"
bedeutet ja eigentlich das etwas angefangenes noch nicht fertig ist.
Sorry bin gerade einfach zu dämlich die Lösung zu finden sitze schon stundenlang am Quellcode.
mein Code:
public partial class Form1 : Form { private int hr, min, sec; private string word; public Form1() .... //Search Function } private void Enter_Click(object sender, EventArgs e) { string[] words = Search.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.Gold; } else break; startIndex += wordStartIndex + word.Length; } } } // Clear search private void Clear_Click(object sender, EventArgs e) { richTextBox1.SelectionStart = 0; richTextBox1.SelectAll(); richTextBox1.SelectionBackColor = Color.White; }
Antworten
-
Hallo,
was soll ich sagen, du benutzt dein Feld word nicht...
In Enter_Click hast du zwar eine Variable word, aber diese deklarierst du im Kopf der foreach-Schleife, daher wird dort nicht das Feld benutzt.
Für was das Feld gedacht war musst du aber selbst wissen.
Viele Grüße, Tom Lambert - MVP, MCC und MSP
Wozu Antworten markieren und Posts bewerten? Klicke hier
Nützliche Links: .NET Quellcode | C#/VB.NET Konverter | GitHub Forum Samples | Account bestätigen (Verify Your Account)
Ich: Webseite | Facebook | Twitter | Code Snippets | GitHub- Als Antwort vorgeschlagen Dimitar DenkovMicrosoft contingent staff, Administrator Montag, 9. Januar 2017 14:57
- Als Antwort markiert Dimitar DenkovMicrosoft contingent staff, Administrator Donnerstag, 19. Januar 2017 13:31
Alle Antworten
-
Hallo,
was soll ich sagen, du benutzt dein Feld word nicht...
In Enter_Click hast du zwar eine Variable word, aber diese deklarierst du im Kopf der foreach-Schleife, daher wird dort nicht das Feld benutzt.
Für was das Feld gedacht war musst du aber selbst wissen.
Viele Grüße, Tom Lambert - MVP, MCC und MSP
Wozu Antworten markieren und Posts bewerten? Klicke hier
Nützliche Links: .NET Quellcode | C#/VB.NET Konverter | GitHub Forum Samples | Account bestätigen (Verify Your Account)
Ich: Webseite | Facebook | Twitter | Code Snippets | GitHub- Als Antwort vorgeschlagen Dimitar DenkovMicrosoft contingent staff, Administrator Montag, 9. Januar 2017 14:57
- Als Antwort markiert Dimitar DenkovMicrosoft contingent staff, Administrator Donnerstag, 19. Januar 2017 13:31