What's the difference between double quotes and single quote in C#

后端 未结 5 1139
天命终不由人
天命终不由人 2020-12-02 21:49

What\'s the difference between double quotes and single quote in C#?

I coded a program to count how many words are in a file

using System;
using Syst         


        
5条回答
  •  旧巷少年郎
    2020-12-02 22:35

    Single quotes instead of double ones?

    Where? Here? if(text[i] == " ")

    text[i] gives a character/byte and this is compared to an array of (probably unicoded ??) characters/bytes. That does not work well.

    Say: compare '1' with 1
    or "1" with "one" or (2-1) with "eins" what do you think are the correct answers, or is there no meaningful answer anyway?

    Besides that: the program will not work very well with single quotes either, given the example "words.txt" =

    one word or 2 words or more words here ?

提交回复
热议问题