|
You're not using an object oriented design are you? I assume from your variable names that you're doing something with sound equipment?? Typically, you would do something like the following
public class clsSpeaker
{
private string mMake;
private string mModel;
public Speaker()
{
mMake = "";
mModel = "";
}
public void RestoreStateFromQuery(clsResultSet rs)
{
this.mMake = rs.GetColumnValue("SpeakerMake");
this.mModel = rs.GetColumnValue("SpeakerModel");
}
public string Make
{
get
{
return mMake;
}
}
public string Model
{
get
{
return mModel;
}
}
}
...so now, you can just instantiate your clsSpeaker class inside your UI, Deserialize it from your database query, and then do the command that I included in my previous post labeled as "form code." It makes the code much more legible and bug tracing is a lot easier because your code is properly compartmentalized.
btw, put your code in "pre" tags instead of "code" tags...It's a lot easier to read. (Pre tags are what I used to post my code in this thread)
|
|
|
|
|
I want to make a service which can watch and log data send and recived when any internet connection activates. I will be thankful for any pointers and help.
|
|
|
|
|
|
how can we use list for string members
|
|
|
|
|
using System.Collections.Generic;
...
List<string> listOfStrings = new List<string>();
listOfStrings.Add("hello");
listOfStrings.Add("world");
|
|
|
|
|
List<string> strings = new List<string>();
strings.Add("Hello");
Something like this? Your question is not very precise.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hey, I'm making use of Iphlpapi.dll, particularily CreateIpForwardEntry(ref PMIB_IPFORWARDROW pRoute)
I'm a little unclear as to what format I need to be using for the MIB_IPFORWARDROW structure
This is my declaration (?) of the structure:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]<br />
public struct PMIB_IPFORWARDROW<br />
{<br />
public UInt32 dwForwardDest;<br />
public UInt32 dwForwardMask;<br />
public UInt32 dwForwardPolicy;<br />
public UInt32 dwForwardNextHop;<br />
public UInt32 dwForwardIfIndex;<br />
public UInt32 dwForwardType;<br />
public UInt32 dwForwardProto;<br />
public UInt32 dwForwardAge;<br />
public UInt32 dwForwardNextHopAS;<br />
public UInt32 dwForwardMetric1;<br />
public UInt32 dwForwardMetric2;<br />
public UInt32 dwForwardMetric3;<br />
public UInt32 dwForwardMetric4;<br />
public UInt32 dwForwardMetric5;<br />
}
The ones I'm most confused about are dwForwardDest, dwForwardMask and dwForwardNextHop.
If I had a destination network of 10.11.0.0, mask 255.255.0.0 and the 'next hop' would be say... 10.11.7.3. The corresponding 'route add' command that I normally run from the command line is:
route add 10.11.0.0 mask 255.255.0.0 10.11.7.3
I get the feeling that I need to convert each octet to hex, but what do I do from there?
Any help would be greatly appreciated...
|
|
|
|
|
Converting each octet to hex doesn't get you any closer to a number. Instead you should convert each octet into a number, shift them and add them together.
For an example, the IP number 10.11.7.3 would add up as:
(10 << 24) + (11 << 16) + (7 << 8) + 3
---
b { font-weight: normal; }
|
|
|
|
|
I apologize, but I don't really understand what you're instructing me to do, what does (10 << 24) + ... mean?
Does anyone maybe have a bit of example code I could use as a guideline? I've found minimal assistance online so far..
|
|
|
|
|
The << operator shifts the first operand to the left the number of bits specificed by the second operand. As you have four bytes which should be positioned after each other in the uint, you shift the values to place the bytes at the correct position before adding them.
In binary it looks like this:
10 = 00001010
11 = 00001011
7 = 00000111
3 = 00000011
10 << 24 = 00001010000000000000000000000000
11 << 16 = 00000000000010110000000000000000
7 << 8 = 00000000000000000000011100000000
3 = 00000000000000000000000000000011
Adding them together gives the value:
00001010000010110000011100000011
Example code:
uint o1 = 10;
uint o2 = 11;
uint o3 = 7;
uint o4 = 3;
uint code = (o1 << 24) + (o2 << 16) + (o3 << 8) + o4;
---
b { font-weight: normal; }
|
|
|
|
|
OOOhhhhh that makes sense! Thanks a ton.
Should I be using uint instead of uint32? Not 100% sure what the difference is, will look it up a little later...
|
|
|
|
|
uint is just a synonyme for System.UInt32.
---
b { font-weight: normal; }
|
|
|
|
|
b_girl wrote: Should I be using uint instead of uint32? Not 100% sure what the difference is, will look it up a little later...
It's the same, sort of. uint is a C# keyword for the System.UInt32 .NET type.
However, be careful using an unsigned int. It's not CLS compilant, which means that there may exist other .NET languages that might not support unsigned integers/longs.
As long as you use this struct only in your application/dll where the code is not readable from outside (marked as internal , the default one), then you're safe.
But if you plan to use this code within another .NET language which does not support unsigned data types, the you must use int instead of uint
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks... I'll keep that in mind
|
|
|
|
|
|
I did see that earlier but it doesn't show the format I need to put the IP addresses in so that they are accepted. For example dwForwardDest = 10.11.0.0 would obviously not be correct.
|
|
|
|
|
Hi,
Well the title says it all
Anyone know how?
Thanks in advance!
|
|
|
|
|
Are you talking about the actual number of bytes in the file name? Or the number of bytes in a file specified by a file name? For the number of bytes in a file name, figure out which encoding you're interested in (ASCII? Unicode? etc.), then use System.Text.Encoding.[encoding name here].GetBytes .
|
|
|
|
|
Why would anybody want to get the number of bytes of a file name? I think the threadstarter just did not ask precise enough
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Why would anybody want to get the number of bytes of a file name?
I have no idea, but that's certainly not the strangest request I've seen in this forum.
|
|
|
|
|
Someone might want to do something strange like that, but I assumed that if someone was going to do something advanced as that, he would be capable of asking a more precise question.
---
b { font-weight: normal; }
|
|
|
|
|
Contrary to Judah, I assume that you don't want what you are actually asking for, but the size of a file.
To get the size of a file from the name, you use the Length property of the FileInfo class:
FileInfo info = new FileInfo(fileName);<br />
int length = info.Length;
---
b { font-weight: normal; }
|
|
|
|
|
Hi guys,
Sorry if i confused you all.
I'm trying to close a program with a condition.
If the program saved the data to an xml file, it can close. Otherwise it has to remain open.
In order to know if the data is saved, i just ask the size of the file in bytes to see if that has increased or not.
So how do i check the content in bytes of a file?
Thanks in advance!
|
|
|
|
|
Yustme wrote: So how do i check the content in bytes of a file?
You mean the size of the file? If you read my first reply, instead of just replying to it, you will find that I alread answered that question before you even asked it.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
I did. But i got an error, so i thought maybe this wasn't it...
Now i got it fixed tho.
Instead of int, shoulda been long
Thanks for your help!
|
|
|
|