-1

I'm looking to add an excel function in a string that has "" in it.

=SUMPRODUCT((B2:B2000<>"")/COUNTIF(B2:D2000,B2:B2000&""))  

I've tried to use \" but no matter how many of them I add together only 1 displays, same happens when I'm trying to use .Replace or ((char)34).
As Ive already said, I want the output to be "" not ".

Is any way I could get that function as intended?
Im writing this string to a .csv file.
Input: string suma = @"=SUMPRODUCT((B2:B2000<>"")/COUNTIF(B2:D2000,B2:B2000&""))";
Output: Cell A1 =SUMPRODUCT((B2:B2000<>)/COUNTIF(B2:D2000 Cell B1 B2:B2000&"))"
Imput: string suma = "=SUMPRODUCT((B2:B2000<>" + ((char)34) + ((char)34) + ")/COUNTIF(B2:D2000" + ((char)44) + "B2:B2000&" + ((char)34) + ((char)34) + "))";
Output: =SUMPRODUCT((B2:B2000<>")/COUNTIF(B2:D2000,B2:B2000&"))
Input: string suma = "=SUMPRODUCT((B2:B2000<>\"\")/COUNTIF(B2:D2000,B2:B2000&\"\"))";
Output: =SUMPRODUCT((B2:B2000<>")/COUNTIF(B2:D2000,B2:B2000&")) Input: string suma = "=SUMPRODUCT((B2:B2000<>'')/COUNTIF(B2:D2000,B2:B2000&''))"; suma.Replace(@"'",@"&quot;"); Output: =SUMPRODUCT((B2:B2000<>'')/COUNTIF(B2:D2000,B2:B2000&''))

Ionescu
  • 11
  • 5

2 Answers2

2

Use \" to escape the double quotes in C#.

DylanVB
  • 187
  • 1
  • 14
2

Use two double quotes in a row to signify a single double quote within the string literal. If you are using c#, precede the string with @ to indicate a verbatim string.

VB

s = "The word ""chicken"" has 7 letters."

C#

var s = @"The word ""chicken"" has 7 letters.";

You can also use traditional escaping. Just be sure to use the backslash and not the forward slash.

var s = "The word \"chicken\" has 7 letters.";
John Wu
  • 50,556
  • 8
  • 44
  • 80