|
Hi Kwagga.... Thanks for your reply!!
Its an article on creating SOAP headers for WSE3.0, whereas i need HTTP header for general web service call.
Thank you again for your kind reply....
Have a Happy Coding.....
|
|
|
|
|
I have these code:
protected bool EEWrite(UInt16 Address, byte Size, object[] ByteData)
{
bool Status = true;
object[] Data = new object[4 + Size];
Data[0] = SerialNumber;
Data[1] = (byte)0x80;
Data[2] = (UInt16)Address;
Data[3] = (byte)Size;
for(int i = 4; i<=4+Size;i++)
{
Data[i] = (byte)ByteData[i - 4];
}
Status = Device.Write( Data);
return Status;
}
Then i 'd like to write a float number write_number as below:
Status = EEWrite(0x9021, 1, ByteData);
How would i convert a float write_number into ByteData?
Thanks !
|
|
|
|
|
object[] byteData = BitConverter.GetBytes(write_number);
I think that is what you want.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
the code have error:
cannot implicitly convert type 'byte[]' to 'object[]'
|
|
|
|
|
then assign in to a byte array and then if you need that as an object array loop through the byte array and pass each one to an object array.
byte[] ba = BitConverter.GetBytes(write_number);
object[] oa = new object[ba.Length];
for(int i = 0; i < oa.length; i++)
oa[i] = ba[i];
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hey, I'm trying to create a program that would figure out how many times to fold a sheet of paper to get to the moon using recursion and I'm getting a Stack Overflow Error, any thoughts?
const float PageWidth = 0.1F;
const float distanceToMoon = 380000000000;
static void Main(string[] args)
{
Console.WriteLine("You have to fold the sheet of paper " + Moon(1) + " times to get to the moon");
Console.ReadLine();
}
static float Moon(float times)
{
return ((times * PageWidth) > distanceToMoon ? times : Moon(times+1));
}
|
|
|
|
|
Okay, here goes:
0. The stack has a limited size, and every time yoou call the method Moon there is another call on the stack.
1. You are making a shed load [technical term] of recursive calls.
2. Your function will return the distance and not the number of folds.
3. You can only fold a piece of paper seven times.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
williamnw wrote: 3. You can only fold a piece of paper seven times
Regretably, this turns out not to be the case.
Paper_folding[^]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
talk to the hand
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Thanks for your answer. Though:
0. The stack has a limited size, and every time you call the method Moon there is another call on the stack.
Is there something wrong in the algorithm then? Because it's an assignment. If they proposed it I guess it's doable.
1. You are making a shed load [technical term] of recursive calls.
I have to use recursiveness... Not sure what you mean with this one.
2. Your function will return the distance and not the number of folds.
What makes you say this?
3. You can only fold a piece of paper seven times.
Let's suppose it's an imaginary super huge paper that never ends.
Thanks for your answer
|
|
|
|
|
Every fold should DOUBLE the width; i.e. 0.1, 0.2, 0.4, 0.8, 1.6, etc
I mis-read and if your iteraction got there it would return the value.
Try an algorythm the other way:
TimesToFild (paperWidth)
if paperWidth >= distanceToMoon
0 folds needed
else
1 + TimesToFild (paperWidth * 2) needed
Start with a shorter distance say 3 and check your function.
Don't use floats, go double.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi,
you called the function Moon too many times. Try it using e.g. distanceToMoon = 380, then it will work.
You should use e.g. a for loop.
Kind regards
|
|
|
|
|
Shorter distance or lop, the algorithm is wrong!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
It's because you are not folding the paper at all, you are just stacking papers on top of each other.
When folding a paper the thickness will double each time, you are just adding a single sheet of paper each time.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi, thanks for your answer. I hadn't seen it that way. But, are you sure the paper's thickness will double? The first time you do it, sure, but the second time in my head the paper's thickness will be three times the thickness at the beginning, isn't it like that?
|
|
|
|
|
No, the number of layers will double each time.
Try it out with a piece of paper. Fold it once, then again. Count the number of layers that you have, and you see that it's four, not three.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Why do you have to use recursion at all? I'm fairly sure you could use a logarithm to get a better answer, then round it up
x = by
y = logb(x)
380000000000 = 0.1n-1
n-1 = log0.1(380000000000)
n = log0.1(380000000000) + 1
Something like that should do the trick (although I'm rubbish at logarithms, so this might give you the wrong answer, the method should be okay)
|
|
|
|
|
I have to use a recursive function. It's an assignment.
|
|
|
|
|
hi i am beginer of .net
i am facing a problem of disabiling a menustrip in a child for.
when ever i click a confirm button in a child form my menustrip shall be enabled which is of parent mdi form.untill then itt should be disable.
|
|
|
|
|
how are you calling your child form?
something like FormChild.ShowDialog() ?
If so then you can simply do...
if(FormChild.ShowDialog() == DialogResult.OK)
{
this.menuStrip.Enabled = true;
}
Need it in one line?
this.menuStrip.Enabled = FormChild.ShowDialog() == DialogResult.OK;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi
i want use digital pen (or optical pen) in my app which to be written in c#, can anybody help me and give some articles and examples about this issue ?
thanks
|
|
|
|
|
hi
im krishna
did u got any inforamtion or usefull stuffs to
develop an c# application to use the digital pen.
|
|
|
|
|
hi krishna
you can handle mouse_move event.
|
|
|
|
|
Hello to all
How can I use the light pen on the Mvc or the web app?
|
|
|
|
|
I Had to cancel the printing given.
For this I had used
Code Snippet: Sandeep Aparajit playing around with the System.Management.Net namespace.
#region CancelPrintJob
/// <summary>
/// Cancel the print job. This functions accepts the job number.
/// An exception will be thrown if access denied.
/// </summary>
/// <param name="printJobID">int: Job number to cancel printing for.</param>
/// <returns>bool: true if cancel successfull, else false.</returns>
public bool CancelPrintJob(int printJobID)
{
// Variable declarations.
bool isActionPerformed = false ;
string searchQuery;
String jobName;
char [] splitArr;
int prntJobID;
ManagementObjectSearcher searchPrintJobs;
ManagementObjectCollection prntJobCollection;
try
{
// Query to get all the queued printer jobs.
searchQuery = "SELECT * FROM Win32_PrintJob" ;
// Create an object using the above query.
searchPrintJobs = new ManagementObjectSearcher(searchQuery);
// Fire the query to get the collection of the printer jobs.
prntJobCollection = searchPrintJobs.Get();
// Look for the job you want to delete/cancel.
foreach (ManagementObject prntJob in prntJobCollection)
{
jobName = prntJob.Properties["Name" ].Value.ToString();
// Job name would be of the format [Printer name], [Job ID]
splitArr = new char [1];
splitArr[0] = Convert.ToChar("," );
// Get the job ID.
prntJobID = Convert.ToInt32(jobName.Split(splitArr)[1]);
// If the Job Id equals the input job Id, then cancel the job.
if (prntJobID == printJobID)
{
// Performs a action similar to the cancel
// operation of windows print console
prntJob.Delete();
isActionPerformed = true ;
break ;
}
}
return isActionPerformed;
}
catch (Exception sysException)
{
// Log the exception.
return false ;
}
}
#endregion CancelPrintJob
The code line prntJob.Delete() is not executing in other PC's which had .Net framework and all other things same as my Syatem.
What may be the problem? Can anyone say something to solve this?
|
|
|
|