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 6 years ago.
Improve this question
Convert a string into mac address as example 0000001 need to change as 00:00:01 In php i can get it by this $HexVal=rtrim(strtoupper(chunk_split($hexval, 2, ':')),':'); i need exactly same in C#.
I have the first 6 value as 00:01:AB and i got the last six value from a decimal number. If i input 1 then it needs to change as 00:00:01. so then i con-cat to get my full mac as 00:00:AB:00:00:01.
OK got it,,
var temp = Regex.Replace("000001", ".{2}", "$0:");
var tempo = temp.Remove(temp.Trim().Length - 1);//or
var tempo = temp.Trim(':');
Related
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 6 years ago.
Improve this question
I need a regular expression to extract number 513922 from this string.
Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in operation mode
If you insist on regular expression:
string source =
"Error detected (513922: settings can not be applied.), param d1=0.0, d2=0.0 in...";
// 513922
string result = Regex.Match(source, #"(?<=\()[0-9]+(?=:)").Value;
// if you want integer representation:
int number = int.Parse(result);
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 7 years ago.
Improve this question
I have a string that I am grabbing that is input as:
05/22/2015
Eligibility
05/06/2015
Date of Death
I need 05/06/2015. The dates will change as the program runs through a database, and I am just a little unsure on how to always be grabbing the correct one.
So you need the second date only? Is it always going to be the 3rd line? If so you can do
var secondDate = myData.Split(new [] { Environment.NewLine }, StringSplitOptions.None)[2];
If the new line isn't for certain; /n vs /r/n, use:
var secondDate = myDate.Split(Environment.Newline.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[2];
If I understand you correctly, your string has 4 lines and you want the part of the string between linebreak 2 and 3.
Search for the positions of the second and third linebreak \n and use the substring derived of these positions.
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);
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 want convert 1,2,3,4,5,6,7,8,9,10 String to Double.
I tried Convert.ToDouble(String); and Double.Parse(String); but returned 1.0
How to convert multi comma string to double?
Thanks for help.
From the looks of your question you actually have 10 numbers not 1. Use this code:
var nums = "1,2,3,4,5,6,7,8,9,10";
var digits = nums.Split(',').Select(r => Convert.ToDouble(r)).ToArray();
// the result will be an array of doubles, also this only works with .NET 3.5 or better.
Let me know if this works for you.
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
How do i create a six digit sequence number in c# ?
Is there any other way than storing a string in the database like "000000" and later on incrementing it through the last inserted value ?
Use a plain old number as a sequence, this is what your DB will provide. If you want to display it with six digits, just call: yourNumber.ToString("D6")
(see docs)