Results 1 to 3 of 3

Thread: [RESOLVED] C#'s string.Compare vs VB.NET's Operators.CompareString

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    609

    Resolved [RESOLVED] C#'s string.Compare vs VB.NET's Operators.CompareString

    Code:
    using Microsoft.VisualBasic.CompilerServices;
    Code:
    int a = string.Compare("Davis", "DAVIS", false); //-1
    int b = Operators.CompareString("Davis", "DAVIS", false); //1
    int c= string.Compare("Peter", "Davis", false); //1   I expect 1. OK.  
    int d= Operators.CompareString("Peter", "Davis", false); //1 
    int f= Operators.CompareString("Peter", "davis", false); //-1
    I expect a =1 because "a" is greater than "A". But c returns 1 is what I expect. Operators.CompareString always returns what I expect, e.g.b and d return 1, f returns -1.

    Please explain what is C#'s string.Compare difference with Operators.CompareString.
    Last edited by DaveDavis; Jan 10th, 2018 at 08:55 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width