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());
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.
When I use the code below, it compiles but the rest of the code doesn't seem to work. When I take out the Substring part of it, it does.
-Steps
String theDate, theWeekDay;
if (ToTime(Time[0]) == ToTime(0, 0, 0))
{
theDate=ToDay(Time[0]).ToString().Substring(0,3);
theWeekDay=Time[0].DayOfWeek.ToString().Substring(4,8);
DrawTextFixed("day",theWeekDay, TextPosition.BottomRight);
DrawText("day"+Convert.ToString(ToDay(Time[0])),
theWeekDay+" "+theDate,0, Low[0]-TickSize*20, Color.Blue);
}
You haven't given enough information to solve your problem, but if you're just trying to get the day of the week name in the abbreviated format, use this instead:
theWeekDay = Time[0].ToString("ddd");
You're going to have to provide more than just this snippet of code. What is the Time object you're accessing via an indexer? Have you debugged this to see if Time[0] actually has a value? My guess here would be that Time[0] doesn't return a value that DayOfWeek can work with hence Substring(0,3) is being running against either an empty string or a null value
Unless you have omitted part of the code, your assignment does not take place within a class definition or a method.
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");
}
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).