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 12 years ago.
how to pass decimal values over serialport control?
Start by convering whatever values that you want to pass into a byte array (System.Byte()), and then use the SerialPort.Write(Byte(), Int32, Int32) overload to write them to the serial port.
That overload allows you to specify the array of bytes that will be passed, the offset of the array at which to begin, and the number of bytes out of the array that should be passed.
Obviously you've looked already, so you know that you are not going to find an overload for the SerialPort.Write method that writes integer or decimal values directly.
Use SerialPort Class.
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 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.
I am trying to convert this python instruction to C#
int(round(time.time()))
But I cannot figure out what it does exactly.
You need to use UtcNow as opposed to Now or else you will get an answer offset by your timezone.
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
int timestamp = (int) t.TotalSeconds;
time.time() will return the current time as a float which represents seconds since 1/1/1970, round() will round that float to the nearest integer value, and int() will convert the value to the integer type.
For example:
>>> time.time()
1351702579.645324
>>> round(time.time())
1351702580.0
>>> int(round(time.time()))
1351702580
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 have converted Byte[16] to Guid using new Guid(byte[16]) constructor. Now I would like to convert back my guid to byte[16] to compare them, is it possible to do it ?
You could just use Guid.ToByteArray.
Use ToByteArray method.
http://msdn.microsoft.com/en-us/library/system.guid.tobytearray%28v=vs.71%29.aspx
Yes, Guid has a ToByteArray method for exactly this.
Have a look at http://msdn.microsoft.com/en-us/library/system.guid.tobytearray.aspx
Sure - just use Guid.ToByteArray.
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 12 years ago.
How convert delegate (Func) to byte array?
What do you expect a byte[] to mean here?
Note that you can serialize delegates with BinaryFormatter, but that is also serialinh the delegate's target instance etc.
But something like:
byte[] raw;
using(var ms = new MemoryStream()) {
new BinaryFormatter().Serialize(ms, yourDelegate);
raw = ms.ToArray();
}
// use raw somewhere
Note that how useful this is depends on your specific scenario.
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.
explain the rangevalidator control,is it take string also? explain thank you
It supports
Currency
Date
Double
Integer
String
For comparing strings better to use Regularexpressionvalidator instead of Rangevalidator.
In case of type string for the range validator it will only check the character by character, not the length of the string.
Yes, it does support string range validation.
Please look at the documentation before asking question.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.rangevalidator.aspx
MSDN:
The RangeValidator control allows you to check whether a user's entry is between a specified upper and a specified lower boundary. You can check ranges within pairs of numbers, alphabetic characters, and dates. Boundaries are expressed as constants.