|
Thank you Sir. And All the best to you too
|
|
|
|
|
You can use Visual Studio to do it graphically. With the form open (and selected), go to View - Tab Order, and then click on every control in the order you want.
|
|
|
|
|
Use the TabIndex property and make sure TabStop is set to true.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello, im a C# newbie and im having trouble with the transition from C.
In particular with using references in place of pointers.
I have a book called Professional C# but it does not seem to cover what I want to know. Namely, I want to assign a reference to a bool value type, such that I can use it to change the value; or so that I can pass the memory location as a parameter to a method, such that the method will be working on the value the reference points to.
My current understanding is that:
<br />
bool symbol = true; <br />
bool pointer; <br />
<br />
pointer = symbol;
Thanks
Rich
|
|
|
|
|
Take a look at "unsafe" code is C#. You have to use the unsafe keyword for the code block, method or class where you manipulate your pointers. Also, the project needs to have the unsafe flag set in the project properties or command line compile.
|
|
|
|
|
Hi,
first of all, be careful, not all replies are correct or even to-the-point
your example does not contain references or pointers; calling a variable "pointer"
does not turn it into a pointer !
The CLR (that is the system underneath several languages including C#)
lets you work with "value types" (such as int and bool, but also struct) and
"reference types" (such as Form and Button).
A local value type (one declared inside a method) is stored on the stack.
If you pass it as a parameter to another method, it gets copied (or at least
behaves as if it were copied), so that method cannot modify your variable.
Things change when you add the "ref" keyword to your parameter list, both
for caller and callee. Now you are really passing a pointer, and the callee
can modify the caller's variable.
If you're familiar with C, it is like adding a * at the caller, and a & at the
callee (but then all the code of the callee needs additional *, not so in C#).
A reference type is different, it IS a pointer to an object, so when you pass it
to some method, that method can do whatever it chooses to do to your object.
Conclusion: if you have bool symbol=true;
and you want to call a method such that it could change symbol, then do:
someMethod(ref symbol);
May I suggest you buy a book on C# and work your way through it.
I am convinced you need to have a reference book at hand at all times when
starting to use a new language.
Good luck!
|
|
|
|
|
Luc,
Most helpful, I do have a book on C# and had come across the ref keyword.
However I was only using it in the member function declaration and not when I invoked it. I think it did not help that i've jumped in at the deep end with my first app - could have chosen something a bit easier, I am learning quite quickly though!
Cheers all Rich.
|
|
|
|
|
You're welcome.
I still recommend you work your way through the book you have, possibly
skipping those specialized chapters that don't interest you yet.
You really must grasp all the implications of value and reference types
before you can do any serious work.
|
|
|
|
|
Well, I thought I did, but obviously not. I've been trying to do run through the book and code the app at the same time. Guess ill hit the book a bit more...
|
|
|
|
|
Try this one,
http://www.csharphelp.com/archives/archive77.html
|
|
|
|
|
Dear Friends,
I have to validate digital signature inside an XML which we receive from our client. Client has given us their cetificate also which contains their public key. I am using following lines of code to verify the signature but I am getting false everytime. Moreover, .Net framework does not tell what went wrong behind giving this false output value. I am using .Net framework 1.1/C#.
<br />
XmlDocument xmlDoc = new XmlDocument();<br />
xmlDoc.PreserveWhitespace = true;<br />
xmlDoc.LoadXml(SamlXML);<br />
bool validSaml = false;<br />
<br />
X509Certificate cert = X509Certificate.CreateFromCertFile(certificateFileName); <br />
XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);<br />
mgr.AddNamespace("saml",this.samlAssertionNameSpaceURI);<br />
mgr.AddNamespace("ds",this.digitalSignatureNameSpaceURI);<br />
XmlNode nodeSignature = rootNode.SelectSingleNode("//saml:Assertion//ds:Signature",mgr);<br />
if(nodeSignature == null)<br />
{<br />
this.errorNumber = Const.SAML_ASSERTION_SIGNATURE_INVALID_NOT_DEFINED;<br />
this.errorMessage = "ds:Signature node is missing";<br />
return validSaml;<br />
} <br />
<br />
SignedXml verifier = new SignedXml(xmlDoc);<br />
verifier.LoadXml((XmlElement)nodeSignature);<br />
<br />
KeyInfo key = new KeyInfo();<br />
key.AddClause(new KeyInfoX509Data(cert));<br />
verifier.KeyInfo = key;<br />
<br />
if(verifier.CheckSignature())<br />
validSaml = true;<br />
else<br />
validSaml = false;<br />
I am getting false everytime when I call CheckSignature() method. Can someone please help me. I would appreciate any type of help in this matter.
Thanks and Regards,
Amit
|
|
|
|
|
Hi
I'm trying to serialize a class. Everything works fine, but I have problems serializing a property which returns one of my custom types. This is the class:
public MultiSampleType MultiSampleType
{
get { return multisampleType; }
set { multisampleType = value; }
}
public bool VSync
{
get { return vsync; }
set { vsync = value; }
}
public Resolution CurrentResolution
{
get { return resolutions[currentResolution]; }
}
Both MultiSampleType and VSync get serialized, but CurrentResolution does not. I have marked my own class Resolution as [Serializable], but it doesn't work. This class also contains some public properties.
Any suggestions?
thanks in advance
/edit:
Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this. Is there a way to achieve this without it?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: Looks like I also have to define a set accessor in my CurrentResolution. I actually don't want this
But that doesn't make any sence I guess, you will not be able to DeSerialize it without an setter.
All the best,
Martin
|
|
|
|
|
Yeah, makes sense
I just noticed another weird thing though. Deserialization worked fine most of the time, but sometimes I get this:
XmlSerializer serializer = new XmlSerializer(typeof(T));<br />
ret = (T)serializer.Deserialize(stream);
Exception: IvalidOperationException (malformed XML file)
No wonder, the file looks like this at the end:
...
</CurrentResolution>
</ResolutionManager>anager>>
What the hell is wrong with the tag here? Is the serializier messing up something?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Any property that will be serialized/deserialized has to be read/write. So a public field, or a property with both public get and set. It can't serialize if it doesn't have a public get and it can't deserialize if it doesn't allow set.
My article[^] might help.
|
|
|
|
|
Hi,
When you create a Form with the Designer, VS2005 (maybe earlier?) adds code to override the Dipose(bool) method as follows:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
Every time I step through this function in the debugger, components always == null. Am I supposed to be allocating components and adding items to it manually, so that they will be disposed?
|
|
|
|
|
I'm moving from VB to c#, I'm getting there, but one thing has be baffled.
How do i define the length of a string?
for example, if i wanted a string exactly 20 bytes long?
Thanks
|
|
|
|
|
You don't define the length of the string. You just set the string to what you want it to be, e.g.
string myString = "hello world!";
If you need to have a string of a certain length, use a char[] instead, e.g.
char[] theCharacters = { 'h', 'e', 'l', 'l', 'o' };
or alternately
char[] theCharacters = new char[20];
|
|
|
|
|
Thanks for the speedy reply, it was helpful
Looks like my program needs a rewrite ^^
|
|
|
|
|
Although characters aren't necessarily bytes anyway.
|
|
|
|
|
hi all,
i deeply hope that you guys have an answer to my question which is the following:
i've got a menu which controls a couple of user controls representing the pages of my app. only the currently selected page is visible. my problem is that when I resize my app and then switch to another (formerly hidden) page and change its visibility to visible it first paints int its old size and afterwards resizes itself to match the new parent proportions. So basically it is painting twice which is pretty ugly.
Does anyone know how to handle this problem? I'm pretty much stuck
I'd appreciate any help,
thx, Bjoern
|
|
|
|
|
how to match a string from a C# code to a sub-string of a field of a record in a SQL Database??
|
|
|
|
|
Many different ways you can go abouts doing this. SQL Substring Function[^] may help guide your way
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
i think you're looking to use the "LIKE" clause of SQL.
In your SQL statement you'll be doing something like this:
<br />
string myStr = "world";<br />
<br />
string sSQL = "SELECT field from table where field LIKE @mystr;";<br />
<br />
dbcommand.parameters.addwithvalue("@mystr",myStr);<br />
<br />
string mydbvalue = dbcommand.executescalar();<br />
|
|
|
|
|
What would "LIKE" return in this condition:
String to be found:"????2805"
and string that is checked is "2805-2705"
it will still find the sub-string but this is not what we were looking for.... wont it...
|
|
|
|