Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
  • submit to reddit
Func<string, string> RemoveDuplicate = delegate(string s)
            {
                BitArray _arr = new BitArray(256);
                StringBuilder _sb = new StringBuilder();
                s = s.ToLower();
                for (int i = 0; i < s.Length; i++)
                {
                    if (_arr[(int)s[i]])
                    {
                        continue;
                    }
                    else
                    {
                        _arr[(int)s[i]] = true;
                        _sb.Append(s[i]);
                    }
                }
                return _sb.ToString();
            };
Func<string, string> ReverseString = delegate(string s)
            {
                char[] word = s.ToCharArray();
                for (int i = 0, j = (s.Length - 1); i < j; i++, j--)
                {
                    char _temp = word[i];
                    word[i] = s[j];
                    word[j] = _temp;
                }

                return new string(word);
            };
Paul Hammant05/13/12
1507 views
1 replies

Application Development Glass Ceilings

Sometimes in app-dev we’re using technologies that have a delayed cost. Simple to use now, but with shortcomings that mean that later features might be much harder to add. The term ‘Glass Ceilings’ (whilst classically meaning something else) seems to apply here.

Andrew Trice05/13/12
407 views
0 replies

A Response to “Shell Apps and Silver Bullets”

There is an article floating around the web today, warning against “Shell Apps” and tools like PhoneGap. The logic in this article has a few arguments that are misleading, and I’d like to introduce some counter arguments as they relate to PhoneGap and HTML experiences for comparison.

Max De Marzi05/10/12
1901 views
0 replies

Relationships and Relational Databases

Max De Marzi imparts some wisdom in this article by emphasizing the importance of recognizing RELATIONSHIPS in graph databases rather than focusing on objects first.

Tim Murphy05/08/12
964 views
0 replies

Some Thoughts on SharePoint

The main gripe this writer has is that, with the current iteration of SharePoint, you still need to develop on a server instance, which can be a serious barrier for new developers.

        
string strCheck = '';
bool checkString = String.IsNullOrEmpty(strText);
    
        
string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };

IEnumerable<string> query =
  Enumerable.Select (
    Enumerable.OrderBy (
      Enumerable.Where (
        names, n => n.Contains ("a")
      ), n => n.Length
    ), n => n.ToUpper()
  );
  
    
        
string strReverse ="";
string straoriginal = "Test";
if ((string.Compare(strOriginal, strReverse , false)) < 0)
    {
        MessageBox.Show("Less");
    }
    else if ((string.Compare(strOriginal, strReverse , false)) > 0)
    {
        MessageBox.Show("Greater");
    }
    else if ((string.Compare(strOriginal, strReverse , false)) == 0)
    {
        MessageBox.Show("Equal");
    }
    
        
string strReverse ="";
string straoriginal = "Test";
string strReverse= Microsoft.VisualBasic.Strings.StrReverse(strOriginal);
    MessageBox.Show(strReverse); 
    
        
Progessive form 
IEnumerable<string> filtered   = names.Where      (n => n.Contains ("a"));
IEnumerable<string> sorted     = filtered.OrderBy (n => n.Length);
IEnumerable<string> finalQuery = sorted.Select    (n => n.ToUpper());
Output

Harry
Mary
Jay

Jay
Mary
Harry

JAY
MARY
HARRY
 
 
 

 
 

    
        
string string1= "Split function";
string [] SplitString = string1.Split(new Char [] {' '});
MessageBox.Show(Convert.ToString(SplitString [0]));
MessageBox.Show(Convert.ToString(SplitString [1])); 
    
        Fluent query - LINQ

string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };

IEnumerable<string> query = names
	.Where   (n => n.Contains ("a"))
	.OrderBy (n => n.Length)
	.Select  (n => n.ToUpper());
    
        Simple Filter Query 
from n in new[] { "Tom", "Dick", "Harry" }
where n.Contains ("a")
select n

Ouput: Harry    
        
string string1 = "Replace string";
string finalstring= string1 .Replace("replace", "Replaced");
MessageBox.Show("Final Value : " + finalstring);