Thursday, October 9, 2014

Split string by delimiters in C#

This code snippet will work for splitting the string using given delimiters. You can 
change the input string and delimiters at any point of time. 

This additional option let you remove the empty entries from result.
StringSplitOptions.RemoveEmptyEntries 
 
C# Code:
protected void Page_Load(object sender, EventArgs e)
{
     StringBuilder comments = new StringBuilder();
 
     comments.AppendLine("The Big Bang Theory is an American sitcom created by 
                          Chuck Lorre and Bill Prady,");
     comments.AppendLine("both of whom serve as executive producers on the show 
                          along with Steven Molaro.");
     comments.AppendLine("All three also serve as head writers. It premiered on 
                          CBS on September 24, 2007.");  
 
     string[] aryResults = SplitStringByDelimiters(comments.ToString(),  
                                                   new char[] { ',''.''-' });
}
 
string[] SplitStringByDelimiters(string text, char[] delimiter)
{
     return text.ToString().Split(delimiter, StringSplitOptions.None);
}
 
Image:
Split string by delimiters in C#

Monday, September 8, 2014

How to append LinkedList to the end of another LinkedList in C#


One or more generic list can be merged into a single linked list using Concat or AddRange method.
Concat - It concatenate the two linked list.
AddRange - It merge one or more linked list into a single linked list.
 
Example:
    Public List<string> MergeLinkedListMethod1()
    {
        List<string> lstMumbaiAreas = new List<string>();
        List<string> lstChennaiAreas = new List<string>();
        List<string> lstAreas = new List<string>();
 
 
        lstMumbaiAreas = GetMumbaiAreas();
        lstChennaiAreas = GetChennaiAreas();
        
        lstAreas = lstMumbaiAreas.Concat(lstChennaiAreas).ToList();
 
        return lstAreas;
    }
 
    Public List<string> MergeLinkedListMethod2()
    {
        List<string> lstMumbaiAreas = new List<string>();
        List<string> lstChennaiAreas = new List<string>();
        List<string> lstAreas = new List<string>();
 
 
        lstMumbaiAreas = GetMumbaiAreas();
        lstChennaiAreas = GetChennaiAreas();        
 
        lstAreas.AddRange(lstMumbaiAreas);
        lstAreas.AddRange(lstChennaiAreas);
 
        return lstAreas;
    }
 
    public List<string> GetMumbaiAreas()
    {
        List<string> lstMumbaiAreas = new List<string>();
 
        lstMumbaiAreas.Add("Andheri");
        lstMumbaiAreas.Add("Dadar");
        lstMumbaiAreas.Add("Worli");
 
        return lstMumbaiAreas;
    }
 
    public List<string> GetChennaiAreas()
    {
        List<string> lstChennaiAreas = new List<string>();
 
        lstChennaiAreas.Add("Tnagar");
        lstChennaiAreas.Add("Villivakkam");
        lstChennaiAreas.Add("Mount road");
 
        return lstChennaiAreas;
    } 

Wednesday, August 13, 2014

Windows 8.1 wifi showing limited access or no internet access

After updating to Windows 8.1, the wifi internet access status showing limited?
Then, your driver is older.
You need to update new driver. Without having internet, how can i update?
No way. You need to connect internet for update. Use Mobile internet by internet sharing.

How to update new driver?
Here the steps are,
1. Go to device manager.
2. Find Network adapters -> Modem (looks like 801.11 b/g/n)
3. Right Click and select the "Update the driver". It will search online and update your wifi network drivers.
4. Finish. You wifi internet will get connected.

I did. Got updated. Internet is working now.
What about you?
Try it.

Tuesday, April 29, 2014

Object Oriented Programming (OOP)

Object Oriented Programming (OOP) is an approach to designing reusable software systems / application.

Wednesday, April 16, 2014

Windows Phone 8.1 Developer Preview

I have installed Microsoft Windows Phone 8.1 Developer Preview version last night in Lumia 920. It's a great experience while installing through OTA (Over the air).
The WP 8.1 introduced new features which are Cortana digital assistant, Live tile background, Notification / Action center, Wifi sense, Battery saver, Work flow keyboard, Podcast, store etc...
You can get developer copy on registering with App studio / Windows App developer program.

Read here for Windows Phone 8.1 features list.


Thursday, September 5, 2013

Consider for Auto Upgradation in IRCTC booking

The Class of travel may be upgraded automatically to the next higher class. If you do not want to be considered for upgradation, please do not check the option box

So don't check the checkbox.

Friday, August 23, 2013

How to find ASP.NET file upload control file size using javascript ?

The ASP.NET file upload control selected file size can be obtained on javascript. The below code snippet access the fup control object and get the size of the file.

<script type="text/javascript">

        function GetFileSize() {
            alert(document.getElementById("<%=fupUserPhoto.ClientID%>").files[0].size);
        }

</script>

<div>
            <asp:FileUpload ID="fupUserPhoto" runat="server" />
            <br />
            <input type="button" id="btnGetSize" value="Get file size" onclick="GetFileSize()" />
</div>

The size of the file will be returned in byte.