Playing with HashSet
For anyone who likes to do something with sets in C#, this can be a starting point. The full project (VS 2010) is also included. Have fun with programming!
View ArticleSimple Moving Average
I have a project to calculate simple moving average of a data, and the data contains over 4000 values. And requires me to skip the first 14 days and calculate the simple moving average on rest of...
View ArticleSorting a List of complex type by Name property
I'm working on a project that contains 3 different lists. 2 lists of 2 different controls, and 1 list of a custom class. I found that I needed each of these lists sorted. The problem with sorting a...
View ArticlePerformance of String Operations
So, in answering another thread on this forum, I decided to do some performance testing on String. Mainly because a friend of mine said "You should always use new String it's the fastest!". I wasn't...
View ArticleSimple line graph charting
It was tinstaafl who put me on the right track. Click Here I did not know that .NET as of VS 2010 had a charting control! OK, let’s get started! But the learning curve, is as always, a bit steep. MSDN...
View ArticleAdd a row with totals to a DataGridView
Well, start a new forms application from VS. In design mode, drop a DataGridView and a Button on the form and fill in the code. The button clickhandler will add an extra totals row to the datagrid....
View ArticleMaking a DataGridView look like a sudoku board
Btw. this is not a sudoku solver. To gain a deeper insight into the workings of the DataGridView beast (but I begin to love and appreciate it) I decided to make myself a sudoku layout with it. Start a...
View ArticleA Simple Login Form for C#
This is a very simple login form. I set it up so that the form won't close until it's cancelled or a valid username and password are entered. I chained the check for the username and the check for the...
View ArticleSolving the cubic equation using the Complex struct
Complex numbers are seldom used in daily life, altough you could say that every real number is complex, but with the imaginary part equal to zero. And btw. "complex" is a bit of a misnomer, perhaps we...
View ArticleDraw phases of the moon On a form
Lately, I was reading this snippet by vegaseat. I thought, why not do it in C#? But I would also like to add lattitude and logitude in the celestial calculations and draw a picture of the moon at that...
View ArticleFibonacci in C#
Yes, I know Fibonacci(=sun of a good man) again. Most famous for his series, but who among you all, know that he was the man who introduced to the Western world, the Arabic numeral system(including...
View ArticleOnly allow 2 chars to be input in a console application
Many situations arise when you have to choose between two options: true/false, male/female etc. This short snippet will only allow two chars to pass through: capital 'Y' or capital 'N'. The Read and...
View ArticleUsing HttpWebRequest with Cookies
This "FakeWebClient" will allow a C# application to send and receive cookies as part of the request. This behaviour is not available by default. Please note that on line 35 there is a possible...
View ArticleOptions file with comments
This is a really simple way to maintain an options file for your application in case you don't wanna mess with registry entries, along with added support for comments inside the file. The file will be...
View ArticleOn Screen Keyboard
The snippet provided will cover the basics of an on screen keyboard; the only things it doesn't have are numbers, symbols, and extra keys. This will give you the fundementals to build off of. It's...
View ArticlePlotting a function in a Console window in C#
The luxuries we now have in the amount of pixels on a screen to draw some amazing graphs with, were lacking in the early days of computing. Most of the time you had to resort to rude printed output....
View ArticleSmallest form app?
This has by far no practical use. But as I was used to VS, handling most of the code housekeeping "behind the back", I wanted to try to make a Forms program as minimalistic as possible. Start an Empty...
View ArticleSpeech synthesis in .NET, very easy!
Thought it would be very complicated to include speech in your programs. As it seems, in it most simplest form it can be done in two lines. Don't forget to include the System.Speech reference in your...
View ArticleSquaring an integer with extensions
Squaring a number is a rather common task in programming, but if you want to square an integer. Easy you think! Int MySquare = AnInt *.AnInt; This will happily overflow without giving any exception if...
View Article
More Pages to Explore .....