Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to change the double (currency) to 12 digit in c# toString();
For example
12.50 => 000000001250
Try this:
string value = ((decimal)(12.50 * 100)).ToString().PadLeft(12, '0');
int a = (int)(12.50 * 100);
Console.WriteLine((a).ToString("D12"));
Try this
string formattedValue = value.ToString("000000000000");
value being the input and formattedValue as the output.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
My question is how to defined "0x12345678" values in C#?
I have the values from C code (header files), but need to translate them to C#.
// C
#define PARAM_START_ENABLE 0x2b15d3fa
//C#
public const uint PARAM_START_ENABLE = ???
Exactly same way:
public const uint PARAM_START_ENABLE = 0x2b15d3fa;
In C# integer literals can be represented in decimal and hexadecimal forms - specification.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a DataTable with some columns. For example one of this columns contains the next values:
SOMEtext
SOMEnumber
SOMEnumber
SOMEnumber
SOMEtext
SOMEtext
SOMEnumber
SOMEtext
All of these values are strings
How can I count how many 'number' do I have in my table?
Update: A better method to use is Compute():
int count = Convert.ToInt32(
dataTable.Compute("Count(myColumnname)", "myColumnname Like '%number%'"));
You can use the DataTable.Select method:
DataRow[] rows = dataTable.Select("columnname Like '%number%'");
int count = rows.Length;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a typed dataset with a column called price, which is of string datatype. And I'm showing this via ultrgrid/datagrid
How can I show the price in number format.
For example: price ==123456
in the grid it should be like 12,354,56
Try this
var a = price.ToString("##,###,##");
Reference
Custom Numeric Format Strings!
Look at some of the related links to the right of the screen. Some of them even ask the same question as you !
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
SQL statement :
select 'iphone',count(*) from tablename where id=5
Result:
Name Num
'iphone' 50
How should i do with linq to get the same result(SQL statement)?
thanks in advance.
var Result = new { Name = "iPhone", Num = yourSequence.Count(x => x.Id == 5) };
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I would like to split a string in C# for example:
120530
so it will be like this:
Day: 12
Time: 0530
But it will be without spaces, just as it is 120530
How can I do that?
I'm assuming that you know that it will always be 6 digits with the first 2 being day and last 4 being time.
Utilize the Substring() method of your string object...
string allTogether = "120530";
string day = allTogether.Substring(0, 2);
string time = allTogether.Substring(2);
var dayAndTime = "120530";
var day = dayAndTime.Substring(0, 2);
var time = dayAndTime.Substring(2, 4);