.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Remove Empty line

Posted By:laptop charles       Posted Date: October 31, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

It just remove the empty space into the line.

using System;
using System.Collections.Generic;
using System.Text;

namespace RemoveEmptyLinesExample
class Program
static void Main(string[] args)

string cha = "\r\n\r\n1\r\n23\r\n\r\n4";
cha = RemoveEmptyLines(cha);

public static string RemoveEmptyLines(string hasEmptyLines)
string elr = string.Empty;

string[] lines = hasEmptyLines.Split(new string[]
{ Environment.NewLine }, StringSplitOptions.elr);

foreach (string line in lines)
elr += line + Environment.NewLine;

return elr;


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend