CSharp examples for System:String Strip
Removes the terminator ('\0') from a null terminated string.
// Copyright ? 2011, Grid Protection Alliance. All Rights Reserved. using System.Text.RegularExpressions; using System.Text; using System.IO;//from w ww .j av a 2s. c om using System.Globalization; using System.ComponentModel; using System.Collections.Generic; using System; public class Main{ /// <summary> /// Removes the terminator ('\0') from a null terminated string. /// </summary> /// <param name="value">Input string.</param> /// <returns>Returns <paramref name="value" /> with all characters to the left of the terminator.</returns> public static string RemoveNull(this string value) { if (string.IsNullOrEmpty(value)) return ""; int nullPos = value.IndexOf('\0'); if (nullPos > -1) return value.Substring(0, nullPos); else return value; } }