Posts

Showing posts from March, 2015

what does @ do in c# ?

when you want to address an external address the ( \ ) might cause you Errors to prevent or resolve that you can use (  @ ) which means -AT- , it tells the app this is a path for example : 1.wrong , might give you an Error : process.start( " c\:windows\user\you " ); 2. Right : process.start( @ " c\:windows\user\you " );

bubble sort in c# ?

bubble sort , one of simplest  sorting algorithm for small app you write as a student , the reason why its not good for bigger app cause it is slow let me explain it to you the amount of oration need to be done equals = (N-1) it means if you have 1000 number your app will do 999 operation to sort the array or whatever each two neighbor number will be compare together , here is the core of sorting algorithm   for (int i = 1; i < max; i++)             {                 for (int j = 0; j < max - i; j++)                 {                     if (numarr[j] > numarr[j + 1])                     {                         int temp = numarr[j];               ...

Odd and Even number in c#

Image
if you are an software engineering student finding the odd and even number will be your first coding so let me break it to you then we share the code together a number is even when number%2=0 . for example 10%2=0 so its an even number . this % is mod option, not division  the code i wrote was in first semester it will get some numbers and choose using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Collections; namespace zojfard {     class Program     {                  static void Main(string[] args)         {                                      int k;             Console.WriteLine("enter the amount of  numbers you like to do ");    ...

how to get an array from text box in C# ? or as i call it multiple input.

we all no arrays , the difference between arrays and strings is that strings are separated by ( "" )but arrays separated by ( , ) , so what if we want to get an list of numbers into an array from one text box ? to do so simply learn then copy and paste the code below : var number=textBox1.Text.Split(',').Select(s => double.Parse(s.Trim())).ToArray();

open file dialog in c# (2 methods)

Image
you created an app that needs to open an external file manually, for example you created a player in c# and you want to let the user open up files that's why you use openfiledialog which prompt a dialog file and let you choose an specific file. to do here is the code only for openfiledialog  i will provide you two methods 1.for text files 2. windows media player  please add using.sytem.IO namespace first 1.method for text :   //allow you to open a dilogbox and load the file you desire              OpenFileDialog record = new OpenFileDialog();             record.FileName = "";             record.Filter = "Text Files|*.txt";             if (record.ShowDialog() == System.Windows.Forms.DialogResult.OK)             {                 string file = record.Fil...

Tool Tip in C#

Image
when i first started programming , i  wrote an application with many buttons , the only thing that they did say was how to make buttons show information about their function before clicking them . if you check your tools in c# there is some thing called Tool Tip , simply drag and drop it on the object you want to describe , buttons , text box , ...... . after that you will see tool tips under the form design , to enter or edit texts go to solution explorer scroll down and you will see all of your tool tips click on them and enter the description .

what is system Diagnostics in c# ?

Image
using system.Diagnostic ? if you want to open any applications or web pages throw your app, you can simply  use system diagnostics like opening web pages by clicking the buttons or open my computer etc here is a simple code that opens web pages : Namespace:   system.Diagnostics function : process.start("ADDRESS"); 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; using System.Diagnostics; namespace windows_gadget_2 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         private void button1_Click(object sender, EventArgs e)         {        ...

Voice Recognition Code with C#

one day you may wake up i should make an application that can listen to me well here is one of simple sample of  Voice Recognition . By saying the names , face book , youtube , badoo it will open them in browser : feel free to comment using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Speech.Recognition; using System.Speech.Synthesis; using System.Diagnostics; namespace Voice_Recognition {     public partial class Form1 : Form     {         SpeechRecognitionEngine srEngine = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));         object fb ="facebok";         public Form1()         {             InitializeComponent();  ...