With no knowledge of programming what so ever, your series on tic-tac-toe is amazing. The way you just seem to reel the code out at will is impressive. I have a month off soon due to a planned amputation and your series is now going to give me something to 'have a go at' whilst I'm healing. I'm starting understand Excel more and have just started to experiment in VBA and have purchased a VBA for dummies book. Impressed...
This tutorial might have been uploaded 6 years ago but it's still very helpful. I had to create a similar program for my Classes and this has put me in the right direction. So thank you!
Thank you so much for doing a PRACTICAL demonstration. I was getting so sick of learning the dictionary definitions of different programming elements. This is a great change of pace. I will definitely check out the rest of your channel.
This is perfect for someone like me who has already taken courses in C++ and read up on C#. I don't need to start all over from the beginning, which is where most tutors start. I am following this just fine.
I am extremely grateful to you for this tutorial. The code is easy to understand. Your explanation is easy to understand as well. You have made the code nice and clean. I have a game to code in my finals tomorrow which is similar to tic tac toe so this tutorial helped me a ton! Thanks.
Nice tutorial series on C#. I am using the Tic Tac Toe project for a high school programming class. The pace and difficulty works well for new programmers. How about some new projects in the same line of work. Games - connect 4, checkers, card games such as war or memory?
Very nice job at explaining what is going on. I really like this tutorial helped me to better understand how C# works and also how to design my own gui
You've just saved my life! You have the perfect voice for this kind of videos, so firm... plus the ability you have to teach. You're great, thanks. Do you have other tutorials for begginers?
Hello Chris, Through out the video you made it really easy for me to understand what you were doing, but there was a time where you lost me. I couldn't understand the concept you tried to explain around 12:40. Could you try to reexplain me or explain me differently what you meant around 12:40. The concept of "Button b = (Button)sender;" is very abstract me. Thanks, Eddy
When you define the event handler, one of the arguments that the method accepts is defined generically as an object data type (e.g., object sender). The line of code that you are referring to is simply changing the data type of the sender object. We know that the method will only be called when a button is pressed, and so we know that sender WILL BE a button. But because the method defines sender as an object, we have to explicitly convert it from a "generic" object to a button. Button b = (Button) sender; This code casts the sender object as a button, so that now we can access Button methods and Button attributes. If we don't cast it as a button, and we to, for example, get the text of the button without casting it, you would get a compilation error, because the compiler does not know it is a button. So this: sender.Text would not work. And so, we cast the sender object as a Button so that we can do something like this: b.Text Does that help?
you can do it without he whole DisableButtons function. just put your buttons in a table layout and disable it at the there_is_a_winner function :) correct me if i'm wrong
Starting a project to build a kakuro game (c# winform) and needed a little bit of inspiration for creating the ui do watching this tutorial for some hints Don't know if there's even kakuro tutorials out there and don't want to look because I only want hints and ideas, not specific copy/paste code. So hopefully this will help. Edit: great! this gives me ideas for how to tackle several different methods, and a template for how to initialize the ui. I wasn't sure what the best way to allow the user to interact with the ui: buttons will probably work fine enough.
8:45 Adding ; caused an error in VB 2015. Also, I am not seeing a lot of that code you have in your box. Not sure why. Also, your file name is .cs, mine is .vb. Not sure if any of that is a problem.
hi Chris, i'm watching your Tutorial. I write to you because i have little question. After win X or O, we can still push the buttons, i try disable this, because i can't :/ Little help? ;)
It's been 25+ years since I've programmed ZX BASIC (spaghetti coding) and I'm totally new to OOP. Most other tutorials have come from first steps, describing things like variables and arrays which I'm already familiar with. This is just what I need, a top down approach describing a program from start to finish. There are some things I don't understand but I can understand the majority of what you say. I've still to look at more of your work Chris but this has been really useful for me. One thing if you haven't already put it on TH-cam. Could you describe the design stage? You dive straight into coding but you had to come up with the idea for Tic Tac Toe somewhere. I know it's a simplified game but for more complicated projects then you must write things down. How would you go about it?
Essentially the foreach loop iterates through all of the controls on the form. For each component, it tries to convert the control to a button. If that succeeds, then we know that we are looking at a button and not a label (for example). If you tried to cast a label as a Button, it will fail. Once we know that we have a button, we can cast the object as a button and do things to the object that we can do to buttons (like set them as inactive). It's just an easier way to deactivate all of the controls. You could also do b1.active = false; b2.active = false; b3.active = false....etc. It's just a lot more typing! :)
A continuation of this video is available at: (Part 2) Visual Studio Winform Tic Tac Toe Tutorial Example (C#). It adds two features, (1) to keep track of the number of times X, O wins and the number of draws, and (2) to show who's turn it is.
***** the data type bool is relative to the language you are using, not what version of C#. You sure you didn't create a VB.net project vice a C#.net project?
***** Yah, I think MS breaks out different flavors of studio express. There's a web version and a Windows Desktop version. www.visualstudio.com/downloads/download-visual-studio-vs
***** I don't use VS express, I use a full version of Visual Studio. All of my videos so far are winform tutorials with the ASP.net mail app being the only exception. If you want to try and tackle most of these videos, get the Express version for Windows Desktop.
At 26:00 when you are writting to disable the buttons, why do you write "try" and "catch"? i would need a noob explanation cuz im really new at this. Thanks.
+AlickoRule3z Whatever is in the try { } will be attempted at runtime. If the code inside that block fails or throws an exception, the program will drop down to the catch block and execute that code. Without it, you program may crash, or you may have other semantic errors. For example, the following code will print "SAFE": try { int x = 0; int y = 5; Console.WriteLine(y / x); //note you cannot divide by zero, so this would throw a DIV/O exception } catch(Exception ex) { Console.WriteLine("SAFE"); }
Instead of changing the button text to "", it is a better practice to make use of `.Empty`. It makes it a little bit easier for someone else to read the code.
your video is awesome and useful it is a good lesson for beginners like me ...... Can I ask you a question, please I started learning C# by creating Console apps but I spent about 1.5 month till now using this way ...... is moving to another method like this good for me now ? or not ? I can declare functions and reuse them ... please I am waiting for your answer
Thank you so much Chris. You helped me to understand tic-tac-toe game very easily. I followed your tutorials, but I have weird mistake. In the checkForWinner method, messageBox pop-up 10 times... Where am I need to check for this mistake? Thank you and I'll see you at next tutorial ! :)
I've done everything this video shows but as soon as a row of X's are placed nothing happens. No pop up, no disabled buttons, yet my code is literally identical to yours.
wow, well I thought this was going to be easy. Just started a course at college. C# I kind of got stuck but completed it. Anyway thanks I probably learned some more code then i would on a easier tic tac toe tutorial.
I’m in a c# class right now, and I’m geeking over the first 10 minutes of the video. It makes everything so much more practical and aesthetic.
With no knowledge of programming what so ever, your series on tic-tac-toe is amazing. The way you just seem to reel the code out at will is impressive. I have a month off soon due to a planned amputation and your series is now going to give me something to 'have a go at' whilst I'm healing. I'm starting understand Excel more and have just started to experiment in VBA and have purchased a VBA for dummies book. Impressed...
This tutorial might have been uploaded 6 years ago but it's still very helpful. I had to create a similar program for my Classes and this has put me in the right direction.
So thank you!
2020 and this tutorial still rocks. Thanks man.. worked like a charm!
Thank you so much for doing a PRACTICAL demonstration. I was getting so sick of learning the dictionary definitions of different programming elements. This is a great change of pace. I will definitely check out the rest of your channel.
i have tried so many tutorials on tic tac toe and yourse is the only one that worked. Thanks man.
This is perfect for someone like me who has already taken courses in C++ and read up on C#. I don't need to start all over from the beginning, which is where most tutors start. I am following this just fine.
Thank you! This was one of the best guides I have seen in a while - keep up the good work and looking forward for new content
I am extremely grateful to you for this tutorial. The code is easy to understand. Your explanation is easy to understand as well. You have made the code nice and clean. I have a game to code in my finals tomorrow which is similar to tic tac toe so this tutorial helped me a ton!
Thanks.
I LOVE YOU MAN, YOU REALLY SAVED ME, Not because I copyed your code, I truly understanded it! THANKS!
Keep doing video-examples like this one, please!
Nice tutorial series on C#. I am using the Tic Tac Toe project for a high school programming class. The pace and difficulty works well for new programmers. How about some new projects in the same line of work. Games - connect 4, checkers, card games such as war or memory?
Great tutorial.. thanks a million... just started learning C# and this finally gave me a sense of getting somewhere with a practical exercise!
Wow the code is very clear and elegant. I have watched this with pleasure
2 year old video and it still kicks ass! Thank you for this, you are awesome :)
4 year old comment and it still kicks ass! Thank you for this, you are awesome :)
You saved my end of the year project, although im not doing tic tac toe, i never learned how to program games or different thing. You enlightened me!!
Solving exception occurred when we want to disable buttons:
private void disableButtons()
{
foreach(Control c in Controls)
{
if(c.GetType() == typeof(Button))
{
Button b = (Button)c;
b.Enabled = false;
}
}
}
Great! thanks! :)
thanks
Great help!
Thanks!
thank you. this help a lot.
Very nice job at explaining what is going on. I really like this tutorial helped me to better understand how C# works and also how to design my own gui
Why people dislike this kind of very educational videos...
Awesome tutorial! Helped me with my school project!
Thanks Man!! You really helped me out learning C# and Visual Studio!
Chris you can select all the buttons before typing button_click
You've just saved my life! You have the perfect voice for this kind of videos, so firm... plus the ability you have to teach. You're great, thanks. Do you have other tutorials for begginers?
Lol
Thank you so much Chris Merritt. It helped me a lot in making the same.
you're a great teacher!! god bless you
Best tutorial I have ever seen!!!
Amazing Tutorial to follow!
Thanks, great demo for new novice in c#
Chris Merritt can i use text box rather than buttons..
Super helpful, enjoyed creating this - thanks!
Great Tutorial Chris! Keep it up!
thank you for this tutuorial. i was very helpful.
you explain it just like someone that has never programmed before understand it
go so on
This was very helpful, thank you
Thank you very much!!!!Excellent job.
Excellent video ! thank you !!!
I really enjoyed creating tic tac toe :)
it was easy to understand very well thank you
Hello Chris,
Through out the video you made it really easy for me to understand what you were doing, but there was a time where you lost me. I couldn't understand the concept you tried to explain around 12:40. Could you try to reexplain me or explain me differently what you meant around 12:40. The concept of "Button b = (Button)sender;" is very abstract me.
Thanks,
Eddy
When you define the event handler, one of the arguments that the method accepts is defined generically as an object data type (e.g., object sender). The line of code that you are referring to is simply changing the data type of the sender object. We know that the method will only be called when a button is pressed, and so we know that sender WILL BE a button. But because the method defines sender as an object, we have to explicitly convert it from a "generic" object to a button.
Button b = (Button) sender;
This code casts the sender object as a button, so that now we can access Button methods and Button attributes. If we don't cast it as a button, and we to, for example, get the text of the button without casting it, you would get a compilation error, because the compiler does not know it is a button. So this:
sender.Text would not work.
And so, we cast the sender object as a Button so that we can do something like this:
b.Text
Does that help?
Ohhhhh okok yeah thanks a lot man!
thanks a bundle, helped alot in my assignment
you can do it without he whole DisableButtons function. just put your buttons in a table layout and disable it at the there_is_a_winner function :)
correct me if i'm wrong
Nice.......very simple.......Thank you............!!
Very good video! thank you very much!
Great work. Thanks for tutorial!!
what I would recommend in 2013 users is take the button text clear and put it before the button text enable as otherwise it flashs
Thanks Bro.
Easy To Understand.
cool tutorial!
Oh, my english isn't well, but I have understood almost everything that you explained. Thx
what is bool?
Starting a project to build a kakuro game (c# winform) and needed a little bit of inspiration for creating the ui do watching this tutorial for some hints
Don't know if there's even kakuro tutorials out there and don't want to look because I only want hints and ideas, not specific copy/paste code.
So hopefully this will help.
Edit: great! this gives me ideas for how to tackle several different methods, and a template for how to initialize the ui. I wasn't sure what the best way to allow the user to interact with the ui: buttons will probably work fine enough.
can u explain the Button b = (button)sender; part again? i did not understood it, what exactly does it do?
Amazing thank you so much for the tutorial
Thank you so much! It helped me a lot.
Thanks.. you make it so simple
8:45 Adding ; caused an error in VB 2015. Also, I am not seeing a lot of that code you have in your box. Not sure why. Also, your file name is .cs, mine is .vb. Not sure if any of that is a problem.
Very impressive thank you alot 😍
hi Chris, i'm watching your Tutorial. I write to you because i have little question.
After win X or O, we can still push the buttons, i try disable this, because i can't :/
Little help? ;)
ARE YOU LEGIT DUMB HE FIXED THAT IN THE VIDEO
wdym by "i write to you" ?
Very neat tutorial~
i don't have that code screen, how can i get that?
Excellent thank you a lot. Very well explained
It's been 25+ years since I've programmed ZX BASIC (spaghetti coding) and I'm totally new to OOP. Most other tutorials have come from first steps, describing things like variables and arrays which I'm already familiar with.
This is just what I need, a top down approach describing a program from start to finish. There are some things I don't understand but I can understand the majority of what you say. I've still to look at more of your work Chris but this has been really useful for me.
One thing if you haven't already put it on TH-cam. Could you describe the design stage? You dive straight into coding but you had to come up with the idea for Tic Tac Toe somewhere. I know it's a simplified game but for more complicated projects then you must write things down. How would you go about it?
fantastic video !!!
thank you sir, I really get the logic and made it using picture box.
Awesome, thanks for the video
great video, lot of fun to do, thanks:)
great tutorial!
Thank you very much for your helpful video)
around 24:00 can you explain how this disable all button work?
Essentially the foreach loop iterates through all of the controls on the form. For each component, it tries to convert the control to a button. If that succeeds, then we know that we are looking at a button and not a label (for example). If you tried to cast a label as a Button, it will fail. Once we know that we have a button, we can cast the object as a button and do things to the object that we can do to buttons (like set them as inactive). It's just an easier way to deactivate all of the controls. You could also do b1.active = false; b2.active = false; b3.active = false....etc. It's just a lot more typing! :)
A continuation of this video is available at: (Part 2) Visual Studio Winform Tic Tac Toe Tutorial Example (C#). It adds two features, (1) to keep track of the number of times X, O wins and the number of draws, and (2) to show who's turn it is.
***** the data type bool is relative to the language you are using, not what version of C#. You sure you didn't create a VB.net project vice a C#.net project?
*****
Yah, I think MS breaks out different flavors of studio express. There's a web version and a Windows Desktop version. www.visualstudio.com/downloads/download-visual-studio-vs
*****
I don't use VS express, I use a full version of Visual Studio. All of my videos so far are winform tutorials with the ASP.net mail app being the only exception. If you want to try and tackle most of these videos, get the Express version for Windows Desktop.
***** Hey..not sure. I would google it to see the lowest price you can find. If you are a student, you can probably find it pretty cheap.
Chris Merritt If you are a student you can get it for free via Dreamspark
I didn't get the point at 12:19 .
Why you did a cast?
Just recently watched a video about "casting". I got it.
At 26:00 when you are writting to disable the buttons, why do you write "try" and "catch"?
i would need a noob explanation cuz im really new at this.
Thanks.
You are my saver!!! Thank you soo much!!!
How did the Try and Catch fix the issue there? I dont know what they do..
+AlickoRule3z Whatever is in the try { } will be attempted at runtime. If the code inside that block fails or throws an exception, the program will drop down to the catch block and execute that code. Without it, you program may crash, or you may have other semantic errors. For example, the following code will print "SAFE":
try
{
int x = 0;
int y = 5;
Console.WriteLine(y / x); //note you cannot divide by zero, so this would throw a DIV/O exception
}
catch(Exception ex)
{
Console.WriteLine("SAFE");
}
+Chris Merritt Thank you so much!
Very good tutorial :)
Instead of changing the button text to "", it is a better practice to make use of `.Empty`. It makes it a little bit easier for someone else to read the code.
your video is awesome and useful it is a good lesson for beginners like me ...... Can I ask you a question, please I started learning C# by creating Console apps but I spent about 1.5 month till now using this way ...... is moving to another method like this good for me now ? or not ? I can declare functions and reuse them ... please I am waiting for your answer
Any system where DRY is going to be a factor in your code?
Thank you a lot you made my dayy
How would your clear the board if you didn't have new game?
This was very helpful
Well done! I do have one question, however... Why did you only need to check for only 2 diagonals?
What other diagonals should it check for?
is there any other diagonals exists?
Thanks,its helped me a lot.........
Thanks for this!
THANK YOU!!!
Is there any algorithm being used in this??? PLEASE TELL
Thank you so much Chris. You helped me to understand tic-tac-toe game very easily.
I followed your tutorials, but I have weird mistake. In the checkForWinner method, messageBox pop-up 10 times... Where am I need to check for this mistake? Thank you and I'll see you at next tutorial ! :)
Great stuff!
What a beautiful old times the first game I ever created with visual basic
It works on vs 2013 ?????
How we can check either X is winner or 0 is winner..…? Please help me
Is there a way to load previous game outcomes? I mean showing each players exact move for a winning game without a database?
Hello I have a question, I have everything working but my messagebox won't show up when I have a winner, what may be the issue?
I've done everything this video shows but as soon as a row of X's are placed nothing happens. No pop up, no disabled buttons, yet my code is literally identical to yours.
How can i disable just the X && O Buttons and let the others actions in function?
can you make an online shopping tutorial using C#visual studio
wow, well I thought this was going to be easy. Just started a course at college. C# I kind of got stuck but completed it. Anyway thanks I probably learned some more code then i would on a easier tic tac toe tutorial.
lmao you still in college my dude?
How did you want to do the result in a forech part, like you started and then left it at minute 16?
Where does turn comes 🤔
i can't get to switch the players after a press, any advice?
I try to start the app and it says that It cannot load file or assemblies. Any idea how to fix it? I have absolutely no experience with this.
why I am getting a loop of the message box of who wins?
Hello. When I get a Winner it confirms it a lot of times not just a single ok, what is the error ? i am thinking of a foreach ?
is this tutorial oop?