Double quotes in String.Concat [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I want to write
Label "BuildingData" does not exist.
I know how to write using String.format and stringbuilder. I want to write this using String.Concat.
When I write code
String.Concat("Label ","\"","BuildingData","\"", "does not exist.")
The output is
Label \"BuildingData\" does not exist.

Add a space before does and you'll get the correct output. The quotes are a red herring - you're looking in the debugger.
using System;
public class Test
{
public static void Main()
{
var concat = String.Concat("Label ","\"","BuildingData","\"", " does not exist.");
Console.WriteLine(concat);
}
}
Here's the output.

Related

What is the problem with char equal to ","? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last month.
Improve this question
string odp = "2,1";
bool abs = odp[1].Equals(",");
When I do Console.Writeline(odp[i]) it shows "," symbol so why does it equal to false?
I tried using == instead but it doesn't work either. Thanks in advance
A Char is encapsulated in single quotation marks ',' in C# (a String uses double quotation marks ",").
Try the below instead:
string odp = "2,1";
bool abs = odp[1].Equals(','); // true

c# Registry can't open Subkey with {} [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 11 months ago.
Improve this question
Here is my code
RegistryKey = regsohr;
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
sw.WriteLine(regsohr.GetValue("Path"));
It can't get into {DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}.
But when I delete that line everything works fine.
Anyone has any ideas why it can't open this SubKey?
I will appreciate any help.
My bad.
I have messed up with "HKEY_LOCAL_MACHINE".
regsohr = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Fixed it
regsohr = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{DFDC1B83-7FD3-4C77-8CD1-7391D1680ACA}");
Try this , for example i put it in a Label to check if it works
{
string readValue;
readValue = My.Computer.Registry.GetValue
(#"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache", "Tasks",Nothing);
Label6.Text = readValue;
}

No overload for method 'ReadLine' arguments when only 1 argument is given [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to read the first line in a file, but I keep getting this error every time I do sr.ReadLine(1); and I can not find an answer to this error.
My code:
using (StreamReader sr = new StreamReader(DataStore))
{
string Conent;
Conent = sr.ReadLine(1);
};
As per the docs, the method should be called with no parameters i.e.
sr.ReadLine()
Since I just had and solve a problem like you're facing. Just code
sr.Readline()
Also you might wanna add some Error minimization if you're going to read it line by line in a while/loop like this.
while ((content = sr.Readline()) !=n null && (line != ""))
{
your code
}

ReplaceTest(int i) not all code paths return a value [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
public string ReplaceTest(int i)
{
string rep = this.textBox3.Text;
string reped = rep.Replace("sir, this.textBox3.Text");
}
Like this? this is what i want to do but another error comes up not all code paths return a value
string.Replace() takes two arguments:
the string to replace
the string to use instead
If you want to remove "sir", it means to replace it with an empty string:
string reped = rep.Replace("sir", string.Empty);

When I type static, Visual Studio replaces it with ContextStaticAttribute [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Every time I'd put in static it would keep replacing it with ContextStaticAttribute.
I need 10 rep to post images, but here's the link: http://i.imgur.com/jBOOF3s.png)
I also do not want to have to press the right arrow to put in a local variable!
I just figured out how you did this by typing static inside a method.
Variables in a method cannot be static, only class level elements can.
Simply declare those variables inside the class, not a method.
Example:
namespace ConsoleApplication2
{
class Program
{
static string username; // Correct
private static void Main()
{
static // Incorrect
}
}
}

Categories