Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
The c# standard library currently has a Char.IsSymbol Method here.
Does anyone have any suggestions how I could implement a Char.IsCurrencySymbol method?
Char.IsCurrencySymbol('$')
// true
Char.IsCurrencySymbol('#')
//false
Like this:
public static class Extensions
{
public static bool IsCurrencySymbol(this char c)
{
return char.GetUnicodeCategory(c) == UnicodeCategory.CurrencySymbol;
}
}
Usage:
bool yes = '$'.IsCurrencySymbol();
bool no = '#'.IsCurrencySymbol();
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to C#.
I have a method that returns an object with the List of objects inside.
0 {{DapperRow, RecordedFormID = 'id1'}} object {Dapper.SqlMapper.DapperRow}
1 {{DapperRow, RecordedFormID = 'id2'}} object {Dapper.SqlMapper.DapperRow}
How can I get those ids as strings?
Here is a screenshot
You can use System.Linq namespace and do this:
yourObject.Select(x => x.RecordedFormID);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
class Class1<T>
{
T Value;
void Method1()
{
if(Value is int)
Value = 42;//CS0029
}
}
Is there any way to make code like this work?
It is possible, but usually there is something wrong with the code if you need to do this in a generic class.
if (Value is int)
Value = (T)(object)42;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
public class itemObject { public string items; }
values - item = "name1,name2" or items = "item3"
Need linq to split by ',' if exists else one string array.
This doesnt require linq, its the default behaviour of String.Split
var array = items.Split(',');
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to know if a string has any non-whitespace characters in it -- so if it's not null or just full of spaces or tabs. I'm tired of doing this:
if(!String.IsNullOrWhitespace(something))
There is nothing wrong with this, it's just verbose.
This works (since a string is simply an array of Chars)...
something.Any()
...but it breaks if the variable is NULL (and it wouldn't account for whitespace).
I know I can write an extension method for this, but I feel like there should be something in the core C# library that I'm just missing.
You're not missing anything. My recommendation is an extension method:
public static class StringExtensions
{
public static bool HasValue(this string value)
{
return !string.IsNullOrEmpty(value);
}
}
Usage:
if (myString.HasValue()) ...
Why not use String.IsNullOrEmpty? https://msdn.microsoft.com/en-us/library/system.string.isnullorempty(v=vs.110).aspx
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm going to send back data to my sms gateway.first i have a querystring like this.
string mobileNo = Request.QueryString["msisdn"];
int dest = int.Parse(Request.QueryString["shortcode"].ToString());
string messageIn = Request.QueryString["msg"];
string operatorNew = Request.QueryString["operator"];
Then i'm going to assign a variables to it.
public void sendReply(string messageOut)
{
messageOut = "http://mygateway.com/api/mt?msisdn=mobileNo&body=msg&sender=shortcode&key=nvqow9rhfp&product_id=2116&operator=OperatorNew&country=us";
}
But i'm getting operator assignment error..
Check this.This parameter is wrong.this param not supplied.
&body=msg
Please verify your Key & Product id with the gateway owners.