New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of string
C#
/// <summary>
/// Determine if the specified string is blank, where blank is defined 
/// as null, empty or containing only whitespace characters.
/// </summary>
/// <param name="value">string to be evaluated</param>
/// <returns>
/// true if the value is null, empty or contains only 
/// whitespace characters; otherwise false
/// </returns>
static bool IsNullOrWhiteSpace(string value)
by Al Gonzalez   Monday @ 11:05am
Tags: String, LINQ, Any
33 Views
no comments
 
C#
StringBuilder sb = new StringBuilder();
sb.Append("<html><head><style type='text/css'>p{font-family:Arial;font-size:12px;}</style></head><body></br></br>");
sb.Append(String.Format("<p>Dear {0},</p>", privateContact.Name));
sb.Append(String.Format("<p>{0} has started using the Natolli portal to process some of its bookings and has indicated you as being one of their clients.", business.BusinessName));
sb.Append("In order to take advantage of the services being provided you will need to create an account, which should only take two minutes of your time.");
sb.Append("Once an account has been created and for future bookings you will then be able to; track the status of your reports, make bookings directly through the portal, view and download uploaded reports, photos, invoices and statements on line as soon as they are made available.");
sb.Append("Members will be kept informed as and when new releases and features are made available.");
 
string emailBody = sb.ToString();
March 02, 2010 @ 7:36am
12 Views
no comments
 
C#
using System;
using System.Text;
 
namespace ConsoleApplication2 {
    class Program {
        static void Main(string[] args) {
            //ავიღოთ რაიმე სტრინგი
            string s = "me miyvars samyaro imitom rom mze amodis da natels fens yovels";
            //გადავიყვანოთ ბაიტების მასივში, რადგან Convert.ToBase64String ბაიტის მასივს იღებს პარამეტრად
            byte[] strBytes = Encoding.ASCII.GetBytes(s);//თუ გაქვთ უნიკოდური ტექსტი უნდა გამოიყენოთ შესაბამისი კლასი. მაგ Encoding.Unicode
by Zviadi   February 10, 2010 @ 4:47am
25 Views
no comments
 
function getQueryStringParams( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
by pushp   January 21, 2010 @ 2:38am
14 Views
no comments
 
C#
/// <summary>
/// Allows setting of a value in a UrlEncoded string. If the key doesn't exist
/// a new one is set, if it exists it's replaced with the new value.
/// </summary>
/// <param name="urlEncoded">A UrlEncoded string of key value pairs</param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public static string SetUrlEncodedKey(string urlEncoded, string key, string value)
{
by Rick Strahl   November 30, 2009 @ 4:07pm
202 Views
no comments
 
C#
public static class Int32Extensions
{
    /// <summary>
    /// Appends an ordinal to the given integer value.  Reformatted from here:
    /// http://stackoverflow.com/questions/20156/is-there-an-easy-way-to-create-ordinals-in-c/20175#20175
    /// </summary>
    /// <param name="value"></param>
    /// <returns></returns>
    public static string ToStringWithOrdinal(this int value)
    {
by Jon Sagara   November 02, 2009 @ 1:20pm
73 Views
no comments
 
param ([string] $filename)
 
function splitString([string]$string, [int]$length)
{
    $lines = @();
    $stringLength = $string.Length;
    $position = 0;
 
    while ($position -lt $stringLength)
    {
by David R. Longnecker   October 13, 2009 @ 11:00am
183 Views
no comments
 
C#
using System;
using System.Configuration;
 
namespace Microsoft.Samples.AspNet.Validators
{
  class UsingRegexStringValidator
  {
    static void Main(string[] args)
    {
      // Display title.
by Dean Weber   October 07, 2009 @ 7:01am
222 Views
no comments
 
C#
/// <summary>
/// Splits the id seqence values.
/// </summary>
/// <param name="combinedArgs">The combined args.</param>
/// <returns></returns>
private int[] SplitIdSeqenceValues(object combinedArgs)
{
    var args = new int[3];
 
    static readonly Regex _argsSeperator = new Regex(@"\D+", RegexOptions.Compiled);
by kannan M ambadi   September 28, 2009 @ 12:04am
85 Views
1 comments
 
function truncate-string([string]$value, [int]$length)
{
    if ($value.Length -gt $length) { $value.Substring(0, $length) }
    else { $value }
}
by David R. Longnecker   August 25, 2009 @ 7:34am
278 Views
no comments
 
C#
/// <summary>
/// Fixes a plain text field for display as HTML by replacing carriage returns 
/// with the appropriate br and p tags for breaks.
/// </summary>
/// <param name="String Text">Input string</param>
/// <returns>Fixed up string</returns>
public static string DisplayMemo(string htmlText)
{
    if (htmlText == null)
        return string.Empty;
by Rick Strahl   August 03, 2009 @ 3:48pm
Tags: C#, String
108 Views
no comments
 
C#
public static T EnumConverter<T>(string value)
    {
        return (T)Enum.Parse(typeof(T), value);
    }
by Giuliano Lemes   July 28, 2009 @ 6:43am
69 Views
no comments
 
C#
/// <summary>
    /// Extendendo string usando o proprio isnullorempty
    /// assim fica muito mais intuitivo
    /// </summary>
    /// <param name="txt"></param>
    /// <returns></returns>
    public static bool IsNullOrEmpty(this string txt)
    {
        return String.IsNullOrEmpty(txt);
    }
by Giuliano Lemes   July 28, 2009 @ 6:41am
Tags: c#, Strings
106 Views
no comments
 
C#
/// <summary>
    /// Implementaçào do mesmo coalesce do SQL
    /// </summary>
    /// <param name="txt"></param>
    /// <param name="args">passe um numero infinito de string separadas por virgula</param>
    /// <returns></returns>
    public static string Coalesce(this string txt, params string[] args)
    {
        
        string value = string.Empty;
by Giuliano Lemes   July 28, 2009 @ 6:39am
Tags: c#, Strings
87 Views
no comments
 
C#
/// <summary>
/// Returns an abstract of the provided text by returning up to Length characters
/// of a text string. If the text is truncated a ... is appended.
/// </summary>
/// <param name="Text">Text to abstract</param>
/// <param name="Length">Number of characters to abstract to</param>
/// <returns>string</returns>
public static string TextAbstract(string Text, int Length)
{
    if (Text.Length <= Length)
by Rick Strahl   July 20, 2009 @ 5:32pm
Tags: C#, String
347 Views
2 comments
 
C#
/// <summary>
/// Generates a unique Id as a string of up to 16 characters.
/// Based on a GUID and the size takes that subset of a the
/// Guid's 16 bytes to create a string id.
/// 
/// String Id contains numbers and lower case alpha chars 36 total.
/// 
/// Sizes: 6 gives roughly 99.97% uniqueness. 
///        8 gives less than 1 in a million doubles.
///        16 will give full GUID strength uniqueness
by Rick Strahl   July 09, 2009 @ 4:21pm
84 Views
no comments
 
C#
/// <summary>
/// Strips a string of any leading whitespace that exists
/// for all lines of the string.
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static string StripIndentation(string code)
{
    // normalize tabs to 3 spaces
    string text = code.Replace("\t", "   ");
by Rick Strahl   July 06, 2009 @ 11:03pm
Tags: C#, String
81 Views
2 comments
 
C#
public string GetCodeLines(string code, int count)
{
    string[] lines = code.Split( new string[3]  { "\r\n", "\n", "\r"}, 
                                 StringSplitOptions.None );
 
    string result = string.Join("\r\n", lines.Take(10).ToArray() );
    return result;
}
by Rick Strahl   July 02, 2009 @ 7:19pm
Tags: C#, String
50 Views
no comments
 
C#
string text = @"
This is 
a long winded
text
demonstration
of this funky 
text behavior.";
 
string[] list = text.Split( new string[3] { "\r\n","\r","\n" },
                            3,StringSplitOptions.RemoveEmptyEntries);
by Rick Strahl   July 02, 2009 @ 6:47pm
Tags: C#, String
81 Views
no comments
 
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate