It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can I format this decimal: 123456789012345678
to a string "1.234.567.890,12345678"?
Thanks!
Look here for additional information about custom formats of numbers (of any type)
public string SpecialFormatDecimal(decimal input)
{
return (input / 100000000).ToString("#,##0.00000000", System.Globalization.CultureInfo.GetCultureInfo("en-US"));
}
A simple search on google showed the answer right away.
If you need local decimal point and thousand separator you can leave out the CultureInfo.
Casperah answer is great, but don't forget, that you can use standard numeric format
public string SpecialFormatDecimal(decimal input)
{
return (input / 100000000).ToString("N8");
}
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I try just an old VB application in c# to convert, while I've encountered this line of code:
Mid(strData, intPosition + 1, intLenght) = strValue
How can it be translated into c#?
You would have to combine Remove and Insert, something like:
strData.Remove(intPosition, intLenght).Insert(intPosition, strValue);
The above assumes that the length of strValue was equal to intLenght. If strValue might be longer, then to replicate the Mid statement, we would need to do:
strData.Remove(intPosition, intLenght)
.Insert(intPosition, strValue.Substring(0, intLenght));
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm stacking of how to change these lines to be ToString()method
c1.DisplayComputerSummary();
c2.DisplayComputerSummary();
Console.WriteLine();
Thanks
You may be asking how to program custom output when an object is printed to the console via the ToString() method. You can override the ToString() method the class that c1 and c2 are types of:
public override string ToString()
{
return DisplayComputerSummary();
}
Then in your program you can use it as:
Console.WriteLine(c1.ToString());
Console.WriteLine(c2.ToString());
Console.WriteLine();
Or even just:
Console.WriteLine(c1);
Console.WriteLine(c2);
Console.WriteLine();
See here for more info on the ToString() method.
Your question is unclear but give this a try,
Console.WriteLine(c1.DisplayComputerSummary().ToString());
Console.WriteLine(c2.DisplayComputerSummary().ToString());
Console.WriteLine(c1.DisplayComputerSummary().ToString() + "-" + c2.DisplayComputerSummary().ToString());
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to format an integer so that it appears first with the 1000's separator (,), but after that with 100's separator (,)
Input:123456789
Output: 12,34,56,789
You can create a NumberFormatInfo that has a NumberGroupSizes array that gives you that format:
NumberFormatInfo info = new NumberFormatInfo();
info.NumberGroupSizes = new int[]{3,2};
Console.WriteLine(123456789.ToString("#,#", info));
Output:
12,34,56,789
This can help you out:
1. the currency depending on the culture,
2. the currency in your wanted format without any cash mark
int iValue = 2879068;
string sValue1 = String.Format("{0:C}", iValue);
string sValue2 = String.Format("{0:#,#.}", iValue);
but in case if you want to have some cash mark, simply do:
{0:$#,#.}//or
{0:#,#.€}
Hope it helps,
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
string last = url.Substring(url.LastIndexOf('/') + 1);
var provisionedSiteRequestRep = provisioningRequestRepository.SelectFirst(new WhereSpecification<ProvisioningRequest>(result => result.SiteUrl.Contains(last.ToString())));
Some time i am getting the null values of last.tosting() so i am getting exception for this code how to resolve this?
You are facing problem on this line
(result => result.SiteUrl.Contains(last.ToString());
Can you please check that SiteUrl is type of string otherwise it not going to work for you.
because last is type of string and Contains is method supported by string type ...
or
otherwise last need to be enumebrable collection and siteurl also enumerable collection than and only than Contains is supported
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Alright, so I've tried to search for it, and yes, I found the answer, but not the explanation of it, I'd like to know the explanation of the following result:
float fib(int num)
{
float result;
if (num==1)
result=0;
else
{
if (num==2)
result=1;
else
result=fib(num-1)+fib(num-2);
}
return result;
}
Start here: http://en.wikipedia.org/wiki/Recursion
Then go here: http://en.wikipedia.org/wiki/Fibbonaci_Series
The method called fib() calls itself in certain cases, and does not call itself in other cases (known as base cases).