hi
I'm new to C# and I didn't have any programming skills.
I'm on my third week now and it seems it's quite complex
I would like to design a code, where it can determine the word type in the sentence.
So, first one must type a sentence and then on the second box, just type a word and check if its present in the first box (from the sentence you typed)
the result should show, true or false.
I started a code but I don't know how to continue: Any idea or suggestion is greatly appreciated:
namespace DisplayWordJaNein
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
i was able to finish it until here and it's working. But what I like is, it will display "Word Found" or let's say true if I'll write a word which is on the sentence itself.
ok, I tried to write: this is my first sentence
and on the 2nd box, if i write "sentence" only it displays "the word can't be found".
so i think i'm on the right track but i'd like that it will give me result "true" if the word i type is on the sentence
thanks
here is my code:
namespace DisplayWordJaNein
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Look up the members of the String class.
From the code I see you use some Visual Studio.
In the menubar you will find something called "Help"
Click on it and choose Search. In the window that appears type String members
You will find what you where looking for.
Take a look at string.Contains() or string.Compare() instead of string.Equals(). You will also need to address the casing of the word (uppercase, lowercase).
I was able to find it. But my next problem is: I would like it that it will also accept the UPPERCASE or LOWERCASE letters if I type in the "enter word to compare".
So that means if I write in the first box like:
This is my sentence
And I'll write in my second box like:
SENTENCE,
that it wil also determine that way.
Is that posible?
Coz in my code, I wrote the big letters SENTENCE but then it didn't find the word.
Shall I make another method for that?
Thanks again
namespace DisplayWordJaNein
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
ok I tried this one, but then it displays the word if I write the word. But the bug is if I only write a letter which a word has, it also displays "Word Found"
I would like that it will only determine the word not the characters.
In this program:
if I type on the first box:
This is my sentence
and type on the 2nd box:
sentence
it will give a result of word found
but then if i type in the first box:
s
it will give a result of word found.
any suggestions?
thanks
if (yourSentence.Contains(yourWord.ToLower()))
{
label4.Text = "Word Found! / ";
}
else
{
label4.Text="The word could not be found.";
}
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.