Questions tagged [null-string]

11 questions
11
votes
3 answers

JsonConvert.SerializeObject: Unexpected result when Serializing null value

In the line of code below, my string x ends up being an actual string "null" when clInitializer.AVOptions = null value: string x = JsonConvert.SerializeObject(clInitializer.AVOptions, new JsonSerializerSettings { NullValueHandling =…
concentriq
  • 359
  • 2
  • 6
  • 16
8
votes
2 answers

C# 7 switch case with null checks

C#7 introduces a new feature called patterns, which you can use with Is-Expression or Switch cases like this: string str = null; switch(str){ case string x: Console.WriteLine("string " + x); break; default: …
8
votes
7 answers

String.IsNullOrEmpty(myString) Vs myString != null

Which one is better among these three? string myString = ""; String.IsNullOrEmpty(myString); vs string myString = ""; if(myString.Length > 0 || myString != null) vs string myString = ""; if (m.Length > 0 | m != null) Former is clearer but is…
Asad
  • 21,468
  • 17
  • 69
  • 94
6
votes
2 answers

Why does [NullString]::Value evaluate differently with a breakpoint?

I've tried this code in PowerShell ISE and VS Code with the same strange result. Without a breakpoint, the output is EMPTY, but with a breakpoint in the line with "NULL", the output is NULL (as expected). Why? function demo { param( …
andiDo
  • 309
  • 4
  • 11
2
votes
1 answer

Passing null string value via environment variable to TSQL script

I have a DOS batch file I want to use to invoke a TSQL program. I want to pass the names of the databases to use. This seems to work. I want to pass the PREFIXES for the names of the tables I want to work with. So for test tables I want to pass the…
elbillaf
  • 1,952
  • 10
  • 37
  • 73
1
vote
2 answers

jQuery serialize method returns null

I am trying to submit the form using jQuery but the serialize method returns null. What's going wrong? Help is very much appreciated. Here is my code. HTML / PHP code
khagolsan
  • 23
  • 4
1
vote
1 answer

EnumDisplayDevices - passing null causes error

The MSDN documentation for EnumDisplayDevices states that passing NULL as the first parameter to the function returns information about the display adaptor(s) on the machine (passing a string returns information about the device with that…
1
vote
2 answers

Error with StringBuilder -- String Not Being Appended

Working with long strings and found this problem. Any advice? I have an instance where a string builder's Capacity is 1024 and Length is 992. I am .Append() a string that has a .Length property of 1024. After .Append() is called, the .ToString()…
bobber205
  • 12,948
  • 27
  • 74
  • 100
0
votes
3 answers

How to pass a string to function and then check if it is equal to a string

#include typedef struct ComplexNumber_S { float realNumber; float img; } ComplexNumber; /** * @brief gets a number * @return the input number */ float GetNumber() { float num; while (scanf_s("%f", 9, &num) != 1) { …
0
votes
1 answer

Simple string return function with default param passed as NULL, returns NULL instead of string

I have the following function: CREATE OR REPLACE FUNCTION public.get_string(cmd_type text, udf_name text, group_name character varying DEFAULT 'usage'::character varying) RETURNS text LANGUAGE plpgsql AS $function$ BEGIN return 'This is the…
0
votes
0 answers

C++ Aborted with basic_string::_M_Construct null not valid

There are some questions with the same error but no one matches with my case. I have two classes: Loader and Processor. The loader loads a vector of string. The processor calls, in the constructor, the Loader method to load and then, for each string…
Yanet
  • 171
  • 1
  • 7