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 8 years ago.
Improve this question
I'm currently working on translating a VB.net program to C# and I'm having an issue with the process.
I'm trying to do the following with ConfigurationManager :
string myNumbers = ConfigurationManager.AppSettings("ClientNumbers");
Where ClientNumbers is a list<string> which works in VB.net but presents me with a "Method, delegate or event is expected" error in C#. I'm not sure why that is and I can't seem to find an answer using my Googling skills.
Thanks, in advance, for any assistance.
simply:
string myNumbers = ConfigurationManager.AppSetings["ClientNumber"];
you need to use the C# indexer which is a square bracket.
You misspelled the brackets
ConfigurationManager.AppSettings["ClientNumbers"];
Simply use this link for conversion http://www.developerfusion.com/tools/convert/vb-to-csharp/
Related
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 1 year ago.
Improve this question
In php, it is possible to directly call a method on a newly created class instance.
(new MyClass())->classMethod();
Is it possible to do this in C#?
Yes, possible, although I am not sure why you need to do it (it is not recommended).
new MyClass().CallMethod();
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 2 years ago.
Improve this question
I have the following code in VBA and wish to convert it to C#
Format(Now(), "m-d-yyyy HAM/PM")
Being pretty green with C# syntax I used the following tool
It gave me the following:
Strings.Format(DateTime.Now(), "m-d-yyyy HAM/PM");
Visual Studio is telling me Strings and Now is wrong.
Please tell me what did I miss here.
Format(Now(), "m-d-yyyy HAM/PM") formats the current date & time according to a time format. The equivalent in C# would be transforming it to a string, since formatting a string is a different operation:
DateTime.Now.ToString("M-d-yyyy htt")
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 have a string and when I try to convert that to a DateTime it's throwing an error. Why?
string str = "3/23/2016 5:10:32 PM";
datetime= convert.ToDateTime(str);
Convert.ToDateTime should work fine if your current culture allows this.
You however have some strange characters in your string... I have copied and pasted it and it didn't work, however writing it directly did.
Check it in a fiddle: https://dotnetfiddle.net/l5nzso
It seems you have some left-to-right mark (0x200E) Unicode characters scattered between the characters in your string. Check it in this other fiddle
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'd like to know how I can take an item selected in my combobox, and convert it to a string variable, which I then use to complete my MySQL query. I'm very much a beginner at C# so any help would be appreciated.
I've tried the following code which I found here on stackoverflow, but it doesn't do the trick. I tried to fill the label1 so I could see if it's working, but I actually need to put it into an mysql query:
string selected0
= this.clubComboBox0.GetItemText(this.clubComboBox0.SelectedItem);
label1.Text = selected0;
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 8 years ago.
Improve this question
I am trying to replace a string content with another but it does not replace
string oldValue= "iif([PricingTKt_US]>0,1-([F221-B01]/iif([PricingTKt_US]=0,1, [PricingTKt_US])),0)";
oldValue=oldValue.Replace("[PricingTkt_US]","[F123]")
Please help me to understand the mistake I am doing.
string oldValue= "iif([PricingTKt_US]>0,1-([F221-B01]/iif([PricingTKt_US]=0,1, [PricingTKt_US])),0)";
PricingTKt_US Capital K.
oldValue=oldValue.Replace("[PricingTkt_US]","[F123]")
PricingTkt_US Small k