The following code example demonstrates how to call the Click event of a Button on Click event of another button. The following code assumes that two Button and one TextBox controls have been instantiated on a form. On the click of the button1, we will generate the click event of the button2 if the the value of the textbox1 is numeric. Continue reading “Click event of a Button on Click event of another button in C#”
Tag: c
Pi: Most widely known mathematical constant
Pi is the most widely known mathematical constant that is commonly defined as the ratio of a circle’s circumference to its diameter approximately equal to 3.14159. It is also represented by the Greek letter “π”. Continue reading “Pi: Most widely known mathematical constant”
Update the xml file using LINQ in C#
This article demonstrates how we can make change the value of an elements in xml document using the LINQ. In this example i have a XML file that contains the data of the employees such as name and salary. Continue reading “Update the xml file using LINQ in C#”
Using int.TryParse() within a LINQ where clause
I pretty new to LINQ, and I’m keen to get more experience using it, so whenever an opportunity arises I like to try writing LINQ queries. I needed to write a method to extract a comma separated list of numbers from a config file, and return this as List. Continue reading “Using int.TryParse() within a LINQ where clause”
How to get the list of all controls of the form
The following code snippet can be use to get the list of all controls of the Windows form. In the example we are using the concept of the recursion. Continue reading “How to get the list of all controls of the form”
How to delete the empty rows in datagridview
With the help of the following example you can remove the all empty rows in your datagridview control. Continue reading “How to delete the empty rows in datagridview”
Open Command prompt window within a Panel control in C#
If you want to open the command prompt window within your windows application, you can use the setparent method of the user32 API. Continue reading “Open Command prompt window within a Panel control in C#”
Gets the hypertext of the specified website using C#
The following example performs a very simple task that shows the use of the System.net namespace to find the hypertext from the given URL. Continue reading “Gets the hypertext of the specified website using C#”
How to know whether a string is found in a text or not in C#
The following code snippet demonstrate how to use regx class to find out whether the specified string is found in a given text or not. From the given code you can search the string into string. Continue reading “How to know whether a string is found in a text or not in C#”
Get all prime numbers up to given number using Sieve of Eratosthenes algorithm in c#
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 5 is prime because only 1 and 5 divide it, whereas 6 is composite because it has the divisors 2 and 3 in addition to 1 and 6. And now if i say that find the all prime numbers up to 6 then there are three numbers 2,3 and 5. Continue reading “Get all prime numbers up to given number using Sieve of Eratosthenes algorithm in c#”