Osama's Weblog

The place where you get updated!
  • rss
  • Home
  • Who am I?
  • RSS Feeds

Visual Studio 2008 Tips and Tricks

Osama | July 16, 2009

So I am back again with another workshop summary. This was conducted by Mr. Adil Mughal. The title was Visual Studio Tips and Tricks.

Though we write code to run our project but we usually dont focus on how organized our code is. I am presenting few points which I learned from the workshop. Though these wont affect the working of project but increase the productivity of a project.

 Understanding & Navigating

  • Swithc among Tabs (Ctrl + Tab)
  • Go to function’s or object’s definition (F12)
  • Find all references of an object or method (Shift + F12)
  • Comments and Uncomments (Ctrl + K, C & Ctrl + K, U)
  • Switch to Designer/Code in web apps (Shift + F7/F7)
  • Format document/Selction (Ctrl + K,D/Ctrl + K, F)
  • Line Number/Go to Line # (Ctrl + G)
  • Collapse to Definition (Ctrl + M, O)
  • Organize Using(s)-> This will remove unused “Usings” from the code and can sort out them. 
Organize Using

Organize Using

 

Modifying & Writing

Refactoring

  • Encapsulate Fields (Ctrl + R, E)
  • Extract Method (Ctrl + R, M)
  • Extract Interface (Ctrl + R, I)
  • Promote Local Variable (Ctrl + R, P)
  • Reorder Variable (Ctrl + R, E)

Code Snippet

  • Insert Code Snippet (Ctrl + K, X)
  • Surround with Snippet (Ctrl + K, S)
  • Code Snippet Manager (Ctrl + K, B)

I hope these will help others while writing their code.

Feel free to contact me

osama_nasir@hotmail.com

  • Share/Bookmark
Comments
No Comments »
Categories
.NET, Uncategorized
Comments rss Comments rss
Trackback Trackback

Network Programming in C#

Osama | July 13, 2009

Programming has always been on the upper half in my preference list. Though I worked on C#, I had to learn more of it. Aiming this, I attended a workshop on Networking Programming in C#, conducted by Munir Usman, assisted by Amir Ali Jiwani, on behalf of DevNext. I am sharing here what I learnt from the workshop.

Network Programming: Instructing a computer programmatically to communicate with other computers.

Before going into programming it is being assumed that the reader is aware of basic networking concepts

  • Sockets
  • Server/Client
  • IP Address
  • Pipes
  • Threads

Libraries which are going to be used are:

System.Net: which is responsible for 

  • System.net.ipaddress // Used for IP Address parsing 
  • Sockets.TcpClient       //Used for creating a client
  • Sockets.TcpListener //Used for Server

 

System.IO   // Used for input/Output purpose

Stream // is a kind of pipe which has two ends one for read and one for write.

networkStream  //  used for read/write on a network, similarly memory stream is used  for memory access

StreamReader // read strings

StreamWriter // write strings

System.threading // used for threads

Now, the scenario is, whenever a client sends TIME command to the server, the server will return current time to the client. Now lets see how does it happen

TcpClient client = new TcpClient(“10.13.0.19″, 8001);   // initiate a new client which connects to the server’s IP as given an port number as given

NetworkStream ns = new NetworkStream(client.Client);  //Initiate a new network strem on recently made client

StreamReader sr = new StreamReader(ns);  //Initiate a new stream which can read on the recently made network stream

StreamWriter sw = new StreamWriter(ns);  //Initiate a new stream which can write on the recently made network stream

//start sending and recieving

string svrMsg = sr.ReadLine();  // read the message sent by the server

Console.WriteLine(svrMsg); // print the message on the console

sw.WriteLine(“time”); //Now send TIME command to the server

sw.Flush(); //Fush() is sued for the message to reach to the server

svrMsg = sr.ReadLine(); //Read the TIME sent by the server

Console.WriteLine(svrMsg); //Print the time on the console

sw.Close();

sr.Close();

ns.Close();

client.Close();

Now lets see server program

TcpListener server = new TcpListener(IPAddress.Parse(“192.168.1.1″), 8005);   //Inititate a server with IP Address and port number
server.Start(); //start the server

 

TcpClient client = server.AcceptTcpClient(); //accept the client connection

 NetworkStream ns = client.GetStream();  // initiate a network stream which could communicate with the client

StreamReader sr = new StreamReader(ns); //initiate a reader stream

StreamWriter sw = new StreamWriter(ns); //initiate a writer stream

sw.WriteLine(“Welcome to the server”); //sends a message to the server

sw.Flush();//make the message to reach the server

 string cmd = sr.ReadLine(); //Read the command sent by the client

    if (cmd == “time”) //check if the command recieved is time

    string var = TIME();

    sw.WriteLine(var); //send the current time to the client

    sw.Flush();

sr.Close();

 sw.Close();

client.Close();

________________________________________________________________________

 

 

For queries feel free to contact me

  • Share/Bookmark
Comments
No Comments »
Categories
.NET, Uncategorized
Comments rss Comments rss
Trackback Trackback

My status

Categories

  • .NET
  • APEX
  • consulting
  • General
  • Oracle CRM on Demand
  • salesforce
  • Uncategorized
  • VisualForce

MM Did You Know?

The number of possible ways of playing the first four moves per side in a game of chess is 318,979,564,000.
Plugin by mmilan

Its all about cloud

Salesforce

.NET .NET 4.0 beta actionFunction actionSupport administrator android APEX Apex variable API button certification cloud computing consulting controller custom DoDirectPayment force.com GET goggles google html images input inputField JavaScript jquery master-detail matcher Parallel Programming parameters pattern paypal query string REGEX regular expression salesforce search url variable Visual Force VisualForce Visual Studio vmware web service XML PARSING DOM SAX STAX

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

My Tweets

Error: Please make sure the Twitter account is public.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox