I see, thanks Tom for the input.
This is considered solved now.
Cheers
I see, thanks Tom for the input.
This is considered solved now.
Cheers
Hi Tom this is what I've got now. And it works fine. Thanks. I have one question in your code. This part I don't understand: Is it the same with instance variables? What is the function?
#region Form Controls
private TextBox _sentence;
private Label _vowelCount;
#endregion
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Daniweb
{
class MainForm: Form
{
//#region Form Controls
//private TextBox _sentence;
//private Label _vowelCount;
//#endregion
private int totalVowels = 0;
public MainForm()
{
InitializeComponent();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (IsVowel(e.KeyData)) ++totalVowels;
else
{
// handle backspacing and deleting if you want
}
UpdateCount();
}
private bool IsVowel(Keys key)
{
return key == Keys.A ||
key == Keys.E ||
key == Keys.I ||
key == Keys.O ||
key == Keys.U;
}
private void UpdateCount()
{
textBox2.Text = "There are " + totalVowels + " vowels.";
}
}
}
Thanks
Hi Tom
I'll re work my code and will let you know for the result
Thank
Hi Tom: this is what I did now:
private void btnCount_Click(object sender, EventArgs e)
{
string yourSentence;
yourSentence = textBox1.Text.ToLower().Trim();
}
private void textBox1_KeyDown(object sender, EventArgs e)
{
string yourSentence;
yourSentence = textBox1.Text.ToLower().Trim();
char ch1 = 'a';
char ch2 = 'e';
char ch3 = 'i';
char ch4 = 'o';
char ch5 = 'u';
int counta = 0;
int counte = 0;
int counti = 0;
int counto = 0;
int countu = 0;
int j = counta + counte + counti + counto + countu;
foreach (char v in yourSentence)
{
if (v == ch1) { counta++; j++; }
else if (v == ch2) { counte++; j++; }
else if (v == ch3) { counti++; j++; }
else if (v == ch4) { counto++; j++; }
else if (v == ch5) { countu++; j++; }
}
if (btnCount_Click(e.KeyData)) ++j;
listBox1.Items.Add("There are " + counta.ToString().Trim() + " a's in the sentence");
listBox1.Items.Add("There are " + counte.ToString().Trim() + " e's in the sentence");
listBox1.Items.Add("There are " + counti.ToString().Trim() + " i's in the sentence");
listBox1.Items.Add("There are " + counto.ToString().Trim() + " o's in the sentence");
listBox1.Items.Add("There are " + countu.ToString().Trim() + " u's in the sentence");
listBox1.Items.Add("All in all there are " + j.ToString().Trim() + " vowels in the sentence");
}
The event is fired for each character. You do not need to loop over everything that has already been tested in the text box. Test just that one character and add to a count field:
public class Form1 { private int _vowels = 0; private void textBox1_KeyDown(object sender, KeyEventArgs e) { // you write IsVowel() if (IsVowel(e.KeyData)) ++_vowels; else { // handle backspacing and deleting if you want } labelCount.Text = _vowels.ToString(); } }
Ok I'll try this Tom. But that means I still have to retain my original code where I have it under:
private void btnCount_Click(object sender, EventArgs e)
is that right?
Btw, if I write the private int _vowels = 0; I got an error saying that expected token. What does it mean?
Thanks
Hi Tom Gunn
Thanks for the short reply.
I've tried the KeyDown Event for the textbox. But everytime I'll write a sentence, it will repeat the counted vowels all the time.
I would like that if I type a sentence for example:
"these are vowels" will display = there are 6 vowels in the sentence.
That means everytime I type, the counter change like from 1,2,3,4,5,6 in the same line.
I'm not sure where my mistakes here in my code:
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
string yourSentence;
yourSentence = textBox1.Text.ToLower().Trim();
int counta = 0;
int counte = 0;
int counti = 0;
int counto = 0;
int countu = 0;
int j = counta + counte + counti + counto + countu;
foreach (char v in yourSentence)
{
switch (v)
{
case 'a':
j++;
break;
case 'e':
j++;
break;
case 'i':
j++;
break;
case 'o':
j++;
break;
case 'u':
j++;
break;
}
}
listBox1.Items.Add("All in all there are " + j.ToString().Trim() + " vowels in the sentence");
listBox1.ForeColor = Color.DeepSkyBlue;
Hi
I'm very new to programming and I'm learning C# for the first time with no experience.
I just finished designing a program which counts the vowels in a sentence.
Now I would like to count the vowels while typing it to the text box. I'm wondering what event/events is/are being used.
I'm not quite sure if it's something to do with "KeyPress" or "KeyUp".
I would appreciate your help. Thanks.
Here is my code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCount_Click(object sender, EventArgs e)
{
string yourSentence;
yourSentence = textBox1.Text.ToLower().Trim();
int counta = 0;
int counte = 0;
int counti = 0;
int counto = 0;
int countu = 0;
int j = counta + counte + counti + counto + countu;
foreach (char v in yourSentence)
{
switch (v)
{
case 'a':
counta++;
j++;
break;
case 'e':
counte++;
j++;
break;
case 'i':
counti++;
j++;
break;
case 'o':
counto++;
j++;
break;
case 'u':
countu++;
j++;
break;
}
}
listBox1.Items.Add("There are " + counta.ToString().Trim() + " a's in the sentence");
listBox1.Items.Add("There are " + counte.ToString().Trim() + " e's in the sentence");
listBox1.Items.Add("There are " + counti.ToString().Trim() + " i's in the sentence");
listBox1.Items.Add("There are " + counto.ToString().Trim() + " o's in the sentence");
listBox1.Items.Add("There are " + countu.ToString().Trim() + " u's in the sentence");
listBox1.Font = new Font("Arial", 11, FontStyle.Bold);
listBox1.ForeColor = Color.DarkViolet;
listBox1.Items.Add("All in all there are " + j.ToString().Trim() + " vowels in …
hi ddanbe
I'm not really sure if I understand the creating a new method.
That means like this:
private void btnOk_Click(object sender, EventArgs e)
{
.....
private void Guess()
const int MaxTries = 3;
for (int Tries = 1; Tries <= MaxTries; Tries++)
{
Guess();
}
}
It seems I'm getting an error. Thanks
Hi sknake,
Thanks for the suggestion I'll give it a try and will post the result. In my code, I had made the restart button which also clears the game and start a new one.
I will concentrate on your question here.
Put all the code inside your OK_Click handler in a new method :
private void Guess()
Inside the OKClick put the following: (just a suggestion here)const int MaxTries = 3; for (int Tries = 1; Tries <= MaxTries; Tries++) { Guess(); } // Do here something when number of guesses is exceeded
Please put your code in code tags.
Hi ddanbe
Thanks for the suggestions. Does that matter where shall I put the new method?
Thanks
Hi
I made a code where user can guess the number. Now I would like to implement the number of tries and I would like that the user will only guess til 3 times. It seems I'm quite lost here.
I tried to declare it as constructors but not sure what's next.
Any idea?
Thanks
namespace Guessing_Game
{
public partial class Form1 : Form
{
private static int randomNumber;
private const int rangeNumberMin = 1;
private const int rangeNumberMax = 10;
private int numTries;
public Form1()
{
InitializeComponent();
randomNumber = GenerateNumber(rangeNumberMin, rangeNumberMax);
}
private int GenerateNumber(int min,int max)
{
Random random = new Random();
return random.Next(min, max);
}
private void btnOk_Click(object sender, EventArgs e)
{
int yourNumber = 0;
Int32.TryParse(textBox1.Text.Trim(), out yourNumber);
if (yourNumber>= rangeNumberMin && yourNumber<=rangeNumberMax)
{
listBox1.Items.Add(yourNumber);
if (yourNumber > randomNumber)
{
listBox2.Items.Add("No the Magic Number is lower than your number");
}
if (yourNumber < randomNumber)
{
listBox2.Items.Add("No, the Magic Number is higher than your number");
}
if(yourNumber==randomNumber)
{
listBox2.Items.Add("You guessed the Magic Number!");
btnRestart.Enabled = true;
}
}
else
{
MessageBox.Show("Please enter a number between " + rangeNumberMin + " to " + rangeNumberMax);
}
}
private void btnRestart_Click(object sender, EventArgs e)
{
listBox2.Items.Clear();
listBox1.Items.Clear();
textBox1.Text = null;
randomNumber = GenerateNumber(rangeNumberMin, rangeNumberMax);
btnRestart.Enabled = false;
}
}
Hi
I'm designing a code where one can guess the Magic Number.
In my code I have this part here where I declared the randomNumber after the class Form1. (the green mark below).
Can somebody tell me what's the name of this part here? Is it static variable? And what about the randomNumber under the InitializeComponent();?
Thanks
public partial class Form1 : Form
{
[B]private static int randomNumber;
private const int rangeNumberMin = 1;
private const int rangeNumberMax = 10; [/B]
public Form1()
{
InitializeComponent();
randomNumber = GenerateNumber(rangeNumberMin, rangeNumberMax);
}
private int GenerateNumber(int min,int max)
{
Random random = new Random();
return random.Next(min, max);
}
regards
C# NewBie
i couldnt open the picture.
when you click on the link, also double click the blurred picture on the left side, it will open
Hi
I'm very new to C# and I'm working on a project in the office where I can practice. At the office I can open the project ok. But if I tried it at home in my own laptop, I'm getting an error.
Yesterday I tried to add the reference for excel which I found under Add Reference - > COM.
It was ok so far, after that I tried to look for Word and I also found it under Add Reference - > COM. But when I installed the Word I got so many errors.
I attached a screenshot for the errors
please see here:
http://www.mypicx.com/05272009/mypic/
Any idea how can I resolve this one? Thanks
ok thanks I'll try that.
oopsss sorry about that i'm supposed to attached the jpg file for the error.
But I don't know what happened. it just didn't attach my file
The error I'm getting was:
"ArgumentException was unhandled" and the code line:
"System.IO.File.WriteAllText(filename, textBox1.Text);" was highlighted
thanks
Hi
I'm new to programming and I'm starting to create a simple notepad, with only 4 buttons (Open, Save, New and Font).
If I open or save I'm getting an error:
This is my code:
//Declare save as a new SaveFileDailog
SaveFileDialog save = new SaveFileDialog();
//Declare filename as a String equal to the SaveFileDialog's FileName
String filename = save.FileName;
//Declare filter as a String equal to our wanted SaveFileDialog Filter
String filter = "Text Files|*.txt|All Files|*.*";
//Set the SaveFileDialog's Filter to filter
save.Filter = filter;
//Set the title of the SaveFileDialog to Save
save.Title = "Save";
//Show the SaveFileDialog
if (save.ShowDialog(this) == DialogResult.OK)
{
//Write all of the text in txtBox to the specified file
System.IO.File.WriteAllText(filename, textBox1.Text);
}
else
{
//Return
return;
}
Any idea?
Thanks for your help in advance
Regards
Hi
i set up my mail in outlook using IMAP. And I've noticed, whenever I deleted or moved emails to my other folder, I'm seeing this crashed out in the emails.
Is there any way I can avoid it this crash out?
Thanks
Hi again
What I would like is that if I don't select any text from my listbox1
the left and right button should be disable. That means it's gray out.
Once I select something from my listbox1 then the right button should be enable, so that I can move the text to the listbox2. And once I moved it, the right button should be grayed-out again
Now if I select text from my listbox2 to be moved to listbox1, the left button should be enable, so that I can move the the text to listbox1. And once I moved it, the left button should be grayed out again.
That's why I set the two buttons as false in the Properties Enable.
Which is, before I select any text, these two buttons are disable or grayed out.
Can you please tell me where is my error?
Thanks
Hi Ramy
I will try this again. The btn_Click on your code is that for both (left and right)?
I have my movement code here:
private void btnToRight_Click(object sender, EventArgs e)
{
if(listBox1.SelectedItem!=null)
{
listBox2.Items.Add(listBox1.SelectedItem);
listBox1.Items.Remove(listBox1.SelectedItem);
//To make the button gray, you have to disable the "btnToRight"
// in the Properties into "False"
btnToRight.Enabled = false;
}
Btw, is there a way I can edit my previous post?
I have to edit some errors in my previous post but it seems I can't find the edit button.
Thanks again
Hi Ramy
I tried your code but it didn't work. I've seen that in your if statements, you maybe forgot to put the brackets. From what I've learned it's not advisable to write the if-statements if they don't have brackets.
I think I have it work you can try this one to see if it also works in your side. I'm not sure why your code didn't work. It might be I did something wrong or what. But you can check.
Btw, do I still have to declare the functions of the two buttons (btnToLeft and btnToRight, or maybe in your case here is the button2 and button1) I have? Because in your example, you only put the listbox1_SelectedIndexChange and listbox2_SelectedIndexChange?
Here is my code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cmdAdd_Click(object sender, EventArgs e)
{
string inputyourText;
inputyourText = textBox1.Text.Trim();
if (inputyourText.Length > 1)
{
listBox1.Items.Add(inputyourText);
textBox1.Text = string.Empty;
}
else
{
MessageBox.Show("Es ist ungültig");
}
}
private void cmdDelete_Click(object sender, EventArgs e)
{
int listBoxSelectedIndex = listBox1.SelectedIndex;
listBox1.Items.RemoveAt(listBoxSelectedIndex);
//Selected "Enabled" in the Properties as false
cmdDelete.Enabled = false;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItem!=null)
{
cmdDelete.Enabled = true;
//You have to declare this code to have the "btnToRight" enabled
//if you select the items in the listbox1
btnToRight.Enabled = true;
}
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
//This is added to have the btnToRight and btnToLeft function
if (listBox2.SelectedItem!=null)
{ …
thanks Ramy I'll try this now and will post the result:-)
hi
I would like to make a code where I can move items from listbox1 to other listbox2 using the button1(as moving the item to listbox2) and button2(as moving the item to listbox1).
I would like that before I click on the items in my listbox1, the button1 will be disabled or grayed out. And the same with my button2.
I already figured out the button1 to work but the button2 seems I have to add something which I'm not sure. Could you please check my code why I'm stuck up? Thanks
Here is the code:
private void btnToRight_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItem != null)
{
listBox2.Items.Add(listBox1.SelectedItem);
listBox1.Items.Remove(listBox1.SelectedItem);
btnToRight.Enabled = false;
}
}
private void btnToLeft_Click(object sender, EventArgs e)
{
if (listBox2.SelectedItem != null)
{
listBox1.Items.Add(listBox2.SelectedItem);
listBox2.Items.Remove(listBox2.SelectedItem);
btnToLeft.Enabled = false;
}
}
private void listBox1_Leave(object sender, EventArgs e)
{
if (listBox1.SelectedItem == null)
{
btnToRight.Enabled = false;
}
else
{
btnToRight.Enabled = true;
}
}
private void listBox2_Leave(object sender, EventArgs e)
{
if (listBox2.SelectedItem == null)
{
btnToLeft.Enabled = false;
}
else
{
btnToLeft.Enabled = true;
}
}
>But I would like to retain the color of the button2 and button3.
Do the same thing, except on button2/button3 instead of panel1.
hmm, what do you mean do the same thing?
>panel1.Height=this.BackColor.ToString();
I'm not entirely sure what you hoped this would do, but if you want to change the color of the panel, you need to change the BackColor property. For example:panel1.BackColor = Color.Yellow;
And this is a separate statement from changing the height.
Thanks Narue, this one works. But I would like to retain the color of the button2 and button3. Not sure if that's possible.
So that means, for example I set the color in button2 as blue and in button3 as green. If I click on button2 I get blue and if I click on the button3 I get the blue and green. Is that possible?
Hi
I created a simple code here just to play C# around. It has 3 buttons and 1 panel.
If you click on the 2nd & 3rd button the panel height changes.
Is that also possible to change the color?
For example :
If I click on the 2nd button, I would like to have it as yellow and at the same time the height changes as well.
and the same with 3rd button.
Thanks :-)
public partial class Form1 : Form
{
public int heightPanel;
public Form1()
{
InitializeComponent();
heightPanel = panel1.Height;
}
private void button1_Click(object sender, EventArgs e)
{
panel1.Height = heightPanel;
}
private void button2_Click(object sender, EventArgs e)
{
panel1.Height = this.Height/2;
}
private void button3_Click(object sender, EventArgs e)
{
panel1.Height = this.Height - 150;
}
}
I have an idea but I don't know where to put this
I think it would be something like this:
panel1.Height=this.BackColor.ToString();
Any inputs?
Thanks
hi Ramy
thanks for the comment. So what I did is, I commented the old examples and just rename the class and add another example.
Regards
If you asked this question to Anders Hejlsberg (The architect of C#) he wouldn't be able answer you. Return back to the example explanation to find out what isRecording is? or at least copy the full code here to be able to guess. I guess it's to indicate file status (saved\unsaved)
Hi Ramy,
thanks. I tried to do a research about isRecording in C# but I didn't find one. Maybe there is, but I didn't understand because I'm a newbie and didn't have any programming experience. It's all new to me...
Anyway, I copied the first part of the code. This is quite complicated:
public static class WordClass
{
public static StringBuilder sb;
private static bool isRecording = false;
private static bool isWritingDocument = false;
public static void WordRecordStart(bool isWritingToDoc)
{
sb = new StringBuilder();
isRecording = true;
isWritingDocument = isWritingToDoc;
}
public static void appendData(string data)
{
if (isRecording) sb.Append(data + Environment.NewLine);
}
public static void WordRecordStop()
{
if (isRecording)
{
// string
string txtName = "Bfa " + DateTime.Now.ToShortDateString() + Guid.NewGuid() + ".txt";
string filename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), txtName);
if (File.Exists(filename))
{
File.Delete(filename);
}
FileMode fm = FileMode.Append;
FileStream fs = new FileStream(filename, fm);
Byte[] byt = Encoding.ASCII.GetBytes(sb.ToString());
fs.Write(byt, 0, byt.Length);
fs.Close();
}
}
Regards
Dear,
How can you want to understand the meaming of this code? You say that it's variable. In fact it is a static data member (field). I think your code uses some sort of status control mechanism and the field name you mentioned is for that purpose.
hi adatapost, thanks for the input. i'm still confuse with the names like fields, methods, properties and arguments,
and also like with public void static or private void static...
but thanks for your input
Hi
I have a code here:
public static StringBuilder sb;
private static bool isRecording = false;
private static bool isWritingDocument = false;
I would like to know what is the role of IsRecording here? I know it's a variable. I would like to understand the meaning here
Thanks
hi
I'm doing an exercise from a book, where I created a project called "Example.cs".
When I wrote the code, here are the steps involve:
1. Select New Item. This causes the Add New Item dialog to be displayed. Select Code File and then change the name to Example.cs,
2.Next, add the file to the project by pressing Add.
3. Next, type the example program into the Example.cs window and then save the file
4. Compile the program by selecting Build Solution from the Build menu.
5. Run the program by selecting Start Without Debugging from the Debug menu.
This is no problem until here. And below of the examples there is a note written like this:
As the preceding instructions show, compiling short sample programs using the IDE involves a number of steps. However, you don’t need to create a new project for each example program in this book. Instead, you can use the same C# project. Just delete the
current source file and add the new file. Then recompile and run.
What does the "Just delete the current source file and add the new file" mean here? How can I do that?
Does that mean, I have to delete the code that I've wrote and rename the Example.cs and do the next exercise?
Thank you
regards
tintincute
hi
thanks! it works-)
also the List<> i tried and it also works
have a good day;-)
ok i'll try that again and will publish the results.
Thanks;-)
i tried this but when I write the "b" to end, I got an error. this is what I've done.
while (true);
//this will loop through all the values in your array IEnumerator basically means you can use it to
//iterate your data
foreach (int num in numbers)
{
Console.WriteLine(" " + num);
}
//System.Collections.IEnumerator Enumerator = numbers.GetEnumerator();
//while (Enumerator.MoveNext())
// Console.WriteLine(" " + Enumerator.Current);
}
Yes. You can still use them. They're not formally obsolete -- they aren't going away.
But it's better to use List<double> because that gives you better type safety and makes your code easier for others to read.
thanks. if i use the List<double> is my code correct here:
btw what does the via the Add Method here means?
//An ArrayList can store any number of items via the Add method
List<double> Prices = new List<double>();
//initialize the total price
double theSumValue = 0.0;
so in looping all the valus I always need this one:
System.Collections.IEnumerator Enumerator = numbers.GetEnumerator();
while (Enumerator.MoveNext())
Console.WriteLine(" " + Enumerator.Current);
is that right?
thanks
Hi
I have a code here composed of Array. I would like to know what does this mean here: (please see last 3 lines)
What does it mean?
Thanks & regards
ArrayList numbers = new ArrayList();
string yourValue;
Console.WriteLine("Give the value (b to end)");
Console.WriteLine();
do
{
Console.WriteLine("Give the value:");
yourValue = Console.ReadLine();
if (yourValue == "b")
break;
numbers.Add(Convert.ToInt32(yourValue));
}
while (true);
System.Collections.IEnumerator Enumerator = numbers.GetEnumerator();
while (Enumerator.MoveNext())
Console.WriteLine(" " + Enumerator.Current);
i see the ArrayList and the System.Collections are already obsolete?
but are they also part of C#?
thanks
hi again,
i would like to know why do I have to add the "using System.Collections;" what is the reason behind?
thanks again
regards
thanks ddanbe:-) now I understand.
it's obvious to me now, as I keep on reading the code. I can see slowly the connections.
It's fun learning C#;-)
Your code still would not compile
int i;
i = 1;
while ( i < 10)
{
j = i * i - 1;
k = 2 * j - 1;
i = i + 1;
Console.WriteLine("The value of i: " + i);
}
Rewrite it like this:int i =1; while ( i < 10) { j = i * i - 1; k = 2 * j - 1; i++;; Console.WriteLine("The value of i: " , i); }
It will print the values 1 to 10 to the console.
ok. if i = i + 1 and i++ are the same, why I can't write in my code the shorthand? And why does my code will not compile?
Thanks again
thanks ddanbe, but i = i + 1 is the same as i++ is that correct?
Thank you for your replies.
ok so J & K doesn't play any important roles here?
I would like to correct the code. I would like to know if this correct.
Thanks
int i;
i = 1;
while ( i < 10)
{
j = i * i - 1;
k = 2 * j - 1;
i = i + 1;
Console.WriteLine("The value of i: " + i);
}
i = 1;
while ( i < 10)
{
j = i * i - 1;
k = 2 * j - 1;
}
I would like to know what's wrong with this code?
Is "i" here the loop variable?
I'm also not sure what's the function of "j" and "k" here. Could you also please explain it to me? I know they are variables...but don't get their function here in the code.
Thanks ;-)
hi it worked. I thought the using.System.Collections.Generic is already the same as using.System.Collections. That's why. But then I tried adding it at the end then it work. I just need to rename some of the variables because it sounds quite different.
like: "Enter the number of prices". I changed it to "Enter the number of items:"
thoughtcoder, thanks. I'm using microsoft visual c# 2008 and trying the examples in the console application.
by the way I would like to know why, do I have to add the "using System.Collections;" what is the reason behind?
thanks for your help again;-)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
hi thanks, i tried it but it didn't work.
i'm not sure if i have to configure here.
hello ddanbe,
thank you for your reply. I did try the code but I'm getting an error.
"Error 1 The type or namespace name 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)"
do I need to create here an additional namespace?
thank you and regards
hello
I wrote a program where I can add the items and if it's more than 250 Euro, 10% discount will be given.
I've used the "if-statement" and I just started only with two numbers. Now, I would like to add as many as I can, is there a way and I would like that the program will stop if there's nothing to add more.
I've researched in Google but it seems I can't find topics on how to deal with it, maybe you guys have an idea. It will be great appreciated.
Thanks, below is my code I made:
This is what I've done:
double firstValue;
double secondValue;
double theSumValue;
Console.WriteLine("The price of the first item:");
firstPrice = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("The price of the second item:");
secondPrice = Convert.ToDouble(Console.ReadLine());
theSumValue = firstPrice + secondPrice;
if(theSumValue >= 250)
theSumValue *= 0.9;
Console.WriteLine("The final value in Euro is " + theSumValue);
hi ddanbe, thanks for the reply.
I think I got and it's working fine. Now this code will also display the word which is written for example in Uppercase or Lowercase.
this is what i did:
thanks guys. I'm starting to enjoy this stuff...
do you know a website where it gives "to do's" or "assignment" for C#. you know for beginners like me. I would like to do some practice. Thanks again
private void button1_Click(object sender, EventArgs e)
{
string yourSentence;
string yourWord;
yourSentence = textBox1.Text.ToLower();
yourWord = textBox2.Text.ToLower();
if (yourSentence.Contains(yourWord))
{
label3.Text = "Word Found!";
}
else
{
label3.Text = "The word can't be found!";
}
}
why is that?
I just would like to display the word which I exactly type, not the letters.
is my code not correct?
thanks