|
Hi,
I have created a structure as follows
public struct symbol
{
char szKeyword;
int dflt;
bool fPassDflt;
int idx;
}
symbol SYM;
I would like to create an array of the structure and write the variables in. I have found a sample in the help for a normal array as follows:
int[,] myArray = new int[,] {{1,2}, {3,4}, {5,6}, {7,8}};
What I want to do is pass the values of the structure but I can't get this to work. Any suggestions?
Thanks
Stephen
|
|
|
|
|
Make a constructor in the struct.
I have given the member variables some more descriptive names, but as I couldn't figure your variable names out, I may be way off what you intended.
I also made the member variables private and made read-only properties for them, so that the structure is immutable.
public struct Symbol {
private char keyword;
private int defibrilator;
private bool passDefibrilator;
private int index;
public symbol( char keyword, int defibrilator, bool passDefibrilator, int index) {
this.keyword = keyword;
this.defibrilator = defibrilator;
this.passDefibrilator = passDefibrilator;
this.index = index;
}
public char Keyword { get { return this.keyword; } }
public int Defibrilator { get { return this.defibrilator; } }
public bool PassDefibrilator { get { return this.passDefibrilator; } }
public int Index { get { return this.index; } }
}
As you have a constructor, you can easily create an array of structures:
Symbol[] symbols = new Symbol[] {
new Symbol('a', 42, true, 1),
new Symbol('b', 8, false, 5),
new Symbol('c', 199866, false, 377378423),
};
---
b { font-weight: normal; }
|
|
|
|
|
|
Can I add Barcode to my C# project?if any body have idea them plz let me know
|
|
|
|
|
Yes. Anything is possible. Search in CodeProject for "Barcode". You will find more than one article...
|
|
|
|
|
how i can add eventhandler to C# application?
|
|
|
|
|
Please be a bit more specific what exactly your problem is
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
How can we create a component that have own context menu on design mode. Well I have see component "Notify Icon" then when we right click while design on IDE we see the menu of "Choose Icon", that menu is optional than other component. How can I add that menu on my component context menu.
Regards,
Ariston Darmayuda.
|
|
|
|
|
Hi All,
I had asked this question earlier...
Why does the cursor moves one tab ahead when i press the
Control + I key combination in the Richtextbox?
Does anyone has a answer to this...
Thanks & Regards,
Everyone is a genius at least once a year - Pramod
|
|
|
|
|
Because the ASCII value of Ctrl-I is 9, which is the Tab character.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave,
Everyone is a genius at least once a year - Pramod
|
|
|
|
|
I recently released a shareware application, and have protected my software with one-way encryption algorythms that allow me to generate cyptographically secure keys which my registered users enter into their application to unlock it. Everything works fine, and it is more than secure enough for my needs.
However, the keys I generate are quite lengthy... like this:
// BEGIN KEY
0wneCg7KCAfJXofTWk2l8opXv3xfCubmRnE5LdsJW3TP0I9WCILizvw2mN5qnugVsp/guotw5XdR2za7ofP761BhdHJpY2sgV2F5Z2hwd2F1Z2hAY29tY2FzdC5uZXRHYXVnZUdsb3cgVG9vbA==
// END KEY
* Note: don't bother trying to use this one (it won't work)
And what I'd really like is a key that looks more like this:
MVE-452-KJ3-2VE
Anyone point me in the right direction?
Stick
|
|
|
|
|
Well, assuming the keys are equally random along their full length, you could use a pre determined portion of the actual key, such as every third character or something.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
An interesting idea. Only downside I see with this is that several keys could result in the same key in the end. Although this is probably not that big a deal.
|
|
|
|
|
As soon as you make your key smaller, you make it less unique, there's not much you can do to avoid that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have created a small Socket server that I wanted to host in a server. I dont know how to host it. Can I host it in a shared hosting or do I need a dedicated hosting. and also what is the hosting requirement. I hjave created the application is .net 2.0
Vikram
|
|
|
|
|
Hi All,
I want to save time from excel file to access database.
excelsheet contain value 3.5 as time,this value I want to store into database datetime field as time.
I don't know it is possible or not.
If anyone know something please share with me.
Thanks,
Nagraj
|
|
|
|
|
Anything is possible.
First, you need to convert that 3.5 into a time such as 3:30, if that is what that means.
Second, save it into a database as a datetime.
Third, your done!
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Hello,
I have an array of, say 40, elements, and I want all the elements to contain 255 when the array is initialized, is there a way to do it?
(like in C++, we did
int array[40] = {255};
)
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
AFAIK there's no such shortcut, so you have to explicitly assign this value to each element:
int[] array = new int[13];
for (int i = 0; i < array.Length; i++)
array[i] = 255;
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi
I'm not sure if I should post here but I'm using C# so I guess it goes here.
Anyways, I'm making a windows application that will access an FTP server over ssl.
I've already enabled SSL on the server and created a certificate.
I've also authenticated this certificate so that the FTP server recognizes it.
I've also added the certificate to my code, and it identifies that the FTPWebRequest request
has added it by the 'request.ClientCertificates.Count'.
Unfortunately, when I run my program, I get this error:
The remote certificate is invalid according to the validation procedure.
Can anyone please help me?:
Here's a snippet of my code:
X509Certificate certificate = new X509Certificate(@"C:\Program Files\Code-Crafters\Ability FTP Server\certs\Sync Testing Certificate.crt");
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(_uploadURI);
request.EnableSsl = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = false;
request.Credentials = new NetworkCredential(_username, _password);
request.ClientCertificates.Add(certificate);
Console.WriteLine("Number of Certificates: {0}", request.ClientCertificates.Count);
try
{
StreamReader sourceStream = new StreamReader(_filepath);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();<font color=red>
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
}
catch (WebException e)
{
FtpWebResponse res = (FtpWebResponse)e.Response;
string error = res.StatusDescription;
Console.WriteLine(error.ToString());
}
-- modified at 23:37 Friday 4th August, 2006
Still learning...
|
|
|
|
|
I'm trying to build a stock market game this game uses the thread too much but the problem is whenever i close the game the game stays in the memory and i can't run again unless i close it manually from the task manager .
Thank you.
Asaad
|
|
|
|
|
I guess you musty mean you are using multiple threads - if so, you need a way to stop those threads when terminating the main program you should either abort those threads, or signal them to stop, and wait for them to reach a thread.join.
A clearer explanation of your problem might help, along with a small sample of the offending code...(read "how to get an answer to your question" at the top).
|
|
|
|
|
Thank you for your reply.
This is the code where i abort the threads
private void Game_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
this.tickerThread.Abort();
this.timerThread.Abort();
this.checkPrice.Abort();
}
catch{}
}
but when i close the program it still work in the background . and i must terminate it manully .
should i add some code or what ?
|
|
|
|
|
Are you catching exceptions in your worker threads? If so, how do you handle ThreadAbortException?
A typical pattern might be:
public volatile bool quit;
public void runtickerThread()
{
try
{
while(!quit)
{
DoStuff();
}
}
catch(ThreadAbortException)
{
Thread.ResetAbort;
quit = true;
}
catch(ApplicationException)
{
}
finally
{
}
}
private void Game_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
this.quit = true;
this.tickerThread.Abort();
this.tickerTread.Join();
}
catch{}
}
|
|
|
|