Click here to Skip to main content
15,885,875 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Breaking news: Many members of microsoft upper management fallen into euphoric coma! Pin
Mark_Wallace9-Apr-20 2:55
Mark_Wallace9-Apr-20 2:55 
GeneralC# puzzle.... Pin
James Curran8-Apr-20 13:00
James Curran8-Apr-20 13:00 
GeneralRe: C# puzzle.... Pin
Nish Nishant8-Apr-20 13:30
sitebuilderNish Nishant8-Apr-20 13:30 
GeneralRe: C# puzzle.... Pin
James Curran8-Apr-20 14:02
James Curran8-Apr-20 14:02 
GeneralRe: C# puzzle.... Pin
Nish Nishant8-Apr-20 14:14
sitebuilderNish Nishant8-Apr-20 14:14 
GeneralRe: C# puzzle.... Pin
Garth J Lancaster8-Apr-20 15:19
professionalGarth J Lancaster8-Apr-20 15:19 
GeneralRe: C# puzzle.... Pin
Nish Nishant9-Apr-20 13:08
sitebuilderNish Nishant9-Apr-20 13:08 
GeneralRe: C# puzzle.... Pin
Nish Nishant8-Apr-20 13:35
sitebuilderNish Nishant8-Apr-20 13:35 
This is the code I ran in release mode. (.NET Core)
C#
class Program
{
    const string _str = "abcdefghijklmnopqrstuvwxyz";

    static void Main(string[] args)
    {
        Foo("A", () => _str.Contains("~"));
        Foo ("B", () => _str.Contains('~'));
        Foo("C", () => _str.IndexOf("~") >= 0);
        Foo("D", () => _str.IndexOf('~') >= 0);
        Foo("E", () => _str.IndexOf("~", StringComparison.Ordinal) >= 0);
    }

    static void Foo(string s, Func<bool> action)
    {
        var sw = new Stopwatch();
        sw.Start();
        for (int i = 0; i < 1000000; i++)
        {
            action();
        }
        sw.Stop();
        Console.WriteLine($"{s} - {sw.Elapsed.Milliseconds}");
    }
}
Nish Nishant
Consultant Software Architect
Ganymede Software Solutions LLC
www.ganymedesoftwaresolutions.com

GeneralRe: C# puzzle.... Pin
Mario Vernari8-Apr-20 20:00
Mario Vernari8-Apr-20 20:00 
GeneralRe: C# puzzle.... Pin
Nelek8-Apr-20 23:09
protectorNelek8-Apr-20 23:09 
GeneralRe: C# puzzle.... Pin
Jörgen Andersson9-Apr-20 1:24
professionalJörgen Andersson9-Apr-20 1:24 
GeneralRe: C# puzzle.... Pin
Greg Utas8-Apr-20 13:56
professionalGreg Utas8-Apr-20 13:56 
GeneralRe: C# puzzle.... Pin
OriginalGriff8-Apr-20 20:07
mveOriginalGriff8-Apr-20 20:07 
GeneralRe: C# puzzle.... Pin
Greg Utas8-Apr-20 23:11
professionalGreg Utas8-Apr-20 23:11 
GeneralRe: C# puzzle.... Pin
Member 147747708-Apr-20 15:11
Member 147747708-Apr-20 15:11 
GeneralRe: C# puzzle.... Pin
Jörgen Andersson8-Apr-20 20:03
professionalJörgen Andersson8-Apr-20 20:03 
GeneralRe: C# puzzle.... Pin
OriginalGriff8-Apr-20 20:09
mveOriginalGriff8-Apr-20 20:09 
GeneralRe: C# puzzle.... Pin
Nish Nishant9-Apr-20 13:10
sitebuilderNish Nishant9-Apr-20 13:10 
GeneralRe: C# puzzle.... Pin
OriginalGriff8-Apr-20 19:54
mveOriginalGriff8-Apr-20 19:54 
GeneralRe: C# puzzle.... Pin
CPallini8-Apr-20 21:45
mveCPallini8-Apr-20 21:45 
GeneralRe: C# puzzle.... Pin
F-ES Sitecore8-Apr-20 23:52
professionalF-ES Sitecore8-Apr-20 23:52 
NewsThe end is nigh! (for OpenVMS) Pin
Kent Sharkey8-Apr-20 10:26
staffKent Sharkey8-Apr-20 10:26 
GeneralRe: The end is nigh! (for OpenVMS) Pin
Ravi Bhavnani8-Apr-20 10:42
professionalRavi Bhavnani8-Apr-20 10:42 
GeneralRe: The end is nigh! (for OpenVMS) Pin
Gary R. Wheeler8-Apr-20 11:33
Gary R. Wheeler8-Apr-20 11:33 
GeneralRe: The end is nigh! (for OpenVMS) Pin
Greg Utas9-Apr-20 3:45
professionalGreg Utas9-Apr-20 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.