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 5 years ago.
Improve this question
Does anyone know how to set the condition in the IF loop for the value of NN010102, and to check only the last two digits? If 01 is to print something, or if 02 is to print something else.
Thank you.
You could use something like this.
string test = "NN010102";
if(test.EndsWith("01"))
{
//print something
}
else if(test.EndsWith("02"))
{
//print something else
}
else
{
//error handling?
}
string foo = "NN010102";
foo.EndsWith("01") ? print1 : print2;
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
if (((Input.GetKeyDown(KeyCode.A)) && (Input.GetKeyDown(KeyCode.LeftShift))) || ((Input.GetKeyDown(KeyCode.RightShift)) && (Input.GetKeyDown(KeyCode.A))))
{
print("Well done! Next Key: " + "A");
}
What's Wrong with this if statement?
It looks like you have too many parentheses on the left side of the OR. Also, your parentheses are not correct on the right side. I believe you want to set it up like this.
if (Input.GetKeyDown(KeyCode.A) && (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)))
Edit: Revised because checking for A twice is redundant as pointed out by #Caius-jard.
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
I am trying to use the libphonenumber-csharp library and the FindNumbers feature. But I am unable to implement it properly. What am I doing wrong?
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
var a = phoneUtil.findNumbers("this is my phone number: (805) 527-9975", null);
Console.WriteLine(a);
Console.Write(phoneUtil.findNumbers("8055279975", "US"));
public Iterable<PhoneNumberMatch> findNumbers(CharSequence text, String defaultRegion);
I tried the code and I am getting this as the output:
java.lang.Iterable1[com.google.i18n.phonenumbers.PhoneNumberMatch]
java.lang.Iterable1[com.google.i18n.phonenumbers.PhoneNumberMatch]
Are you getting the same result? looking into the issue now and I'll let you know if I figure it out.
EDIT
I was able to figure it out!
The correct way to do it is like this:
string testString = "testing the ability to grab here: 345-365-567";
{
PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
PhoneNumber phoneNumber = phoneUtil.Parse(testString, "US");
//now from here you can do ahead and retrieve the number by calling upon phoneNumber.
Console.WriteLine(phoneNumber.NationalNumber);
}
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 5 years ago.
Improve this question
Will the C# function Convert.ToInt32(text) convert different words to the same int? Any links or pushes in the right direction are appreciated!
P.S.
What about anagrams?
No, Convert.ToInt32(text) will just try to parse your text to an int, like:
Convert.ToInt32("032") will return 32 as int but
Convert.ToInt32("Brian") will throw an exception.
I assume that you want to have some kind of hashing, when you say "different words to the same int".
Try GetHashCode(). It will return the same value if you call it multiple times with the same value, for example:
"Brian".GetHashCode() will always return 1635321435
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 5 years ago.
Improve this question
I have a string like:
43965.96000,16933.986,404689.986,5814892.171,77.464,52.47585589,13.59670032,77.464,0.675,-0.223
I want to just keep the string which is bold in characters between commas. How can I do that?
To take your question literally, you could do write a method to split the string by comma and just take the element at the 5th index:
string ParseData(string data)
{
return data.Split(',')[5];
}
So you'll be able to do something like:
string data = "43965.96000,16933.986,404689.986,5814892.171,77.464,52.47585589,13.59670032,77.464,0.675,-0.223";
string result = ParseData(data); // Result = "52.47585589"
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 8 years ago.
Improve this question
i have textedit1.text it has a value 2 in my winform,..and then i have timedit called timePekerjaanStart value 04:00:00 . the case is i wanna addition between textedit1 and timePekerjaanStart ,i catch the result in timestamp called timePekerjaanEnd. so , i wanna get the result timePekerjaanEnd = textedit1 + timePekerjaanStart as like 2 + 04:00:00 = 06:00:00
You've not provided any attempts to solve it yourself but it's really quite straight forward:
var theHoursToAdd = int.Parse(textedit1.Text); // Error handling needs to be added
var startTime = timePekerjaanStart.Time;
timePekerjaanEnd.Time = startTime.AddHours(theHoursToAdd);