28 July 2014

String vs StringBuilder Difference - C#

Introduction :


In this post i am going to explain the difference between String and String Builder in C#. This is a common interview question.

String


String is immutable.Immutable means once we create string object we cannot modify. Any operation like insert, replace or append happened to change string simply it will discard the old value and it will create new instance in memory to hold the new value.

Program

Using System;

public static void Main()
{
  string myString = "Difference";
  myString += " between";
  myString += " String";
  myString += " and";
  myString += " StringBuilder";
}

StringBuilder


String builder is mutable it means once we create string builder object we can perform any operation like insert, replace or append without creating new instance for every time.

Program

Using System.Text;

public static void Main()
{
  StringBuilder myString = new StringBuilder("Difference");
  myString.Append(" between")
  myString.Append(" String")
  myString.Append(" and")
  myString.Append(" StringBuilder")
}

For better understanding see the below table and image


Alvin

                                   !********************* Hope you understand the difference J ***************************!


Reference:

http://www.aspdotnet-suresh.com & Venkat's csharp-video-tuotrials.blogspot.co.uk

22 July 2014

Appear Offline Status - Lync, Office Communicator

Outline:


If you want to stop people from disturbing you when you are busy, you can appear offline in Lync/Office Communicator and u can chat with anyone in offline status in your communicator(OC-2007,Lync 2010 & 2013).


How.? 


1. Exit Lync/Office Communicator

2. Automated Solution - Download and run the reg-edit file

  • Microsoft Lync 2013 users

  • Microst Lync 2010 & Office Communicator 2007 users

3. Click yes and ok for the pop up message.

4. Once you have completed the above steps.Open your Lync/Office communicator and now you can notice a status “Appear Offline” just like Busy/Available/Away etc.
Lync

                                                                      !............... How is it?...............!

20 July 2014

Create your first macro in Excel - VBA

Introduction :


 In this post, I will show you how to create your first macro (VBA program).

Objective :


To create a Macro which will show a Message Box "HELLO WORLD" (world classic "Hello World!" example J)

To write your 1st program and enter into world of VBA, follow the below steps

Steps :


1. Open Excel, and press Alt+F11 (this will open a new window Visual Basic Editor)

2. Click on INSERT >> MODULE



3. Then in the right side window type the below Code
      
      Sub MyFirstMacro()
           Msgbox "Hello World"
      End Sub 

       

4. Then Press the F5 button to Execute(You can also click the Button)

You will see a message box saying "Hello World"You can type whatever you want to see in the message box
we should save the file in .xlsm or .xlsb file extension, so that we can run the macro later


                                        !********************* Try it out J ***************************!

Reference : Microsoft Excel Tutorials - Daily updates (Facebook page)


19 July 2014

How to use Split Function - VBA

Introduction


Split: It is a function that can split a text string into an array, by making use of a delimiter character.

  • As the name tells, the work of Split statement is to break, split or divide a string based on particular criteria.
  • Split Function returns a String Array and not a String.
  • Split (text_stringdelimiterlimitcompare)  - where limit & Compare optional parameter

Objective


Let’s consider we have an Email ID: “someone@gmail.com” and now our objective is to break this email id into username and domain name separately.

Code: Usage of Split function

Sub Get_Domain_and_Username()
  Dim result() As String
  Dim email As String

    email = "someone@gmail.com"
    result() = Split(email, "@")

    domain = result(0)
    userName = result(1)

    MsgBox "Domain is " & domain & "UserName is " & userName
End Sub

Example 2:
Separate a list of Pipe separated names.  eg - "Yuvi|Viru|Msd|Lee"

Objective to get the third name in that list

Sub Splitdemo()
  Dim result() As String
  Dim lists As String

    lists = "Yuvi|Viru|Msd|Lee"
    result() = Split(lists, "|")

    thirdEntry = result(2)
    MsgBox "The third name in the list is: " & thirdEntry
    
    'To Loop all values in the list use the below code
    For i = LBound(result) To UBound(result)
        MsgBox "Name " & i & ": " & result(i)
    Next  
End Sub

                                   !********************* Leave your comments about the topic J ***************************!