|
Hi there,
I had some questions. I was learning c# and i saw this code:
static int amountopen = (0 - 500);
Hmm.. wonder, does it means we are setting a scope from 0 to 500 for integer amountopen?
This is first time i seen.
Oh ya, another added question. How does virtual keyword comes in handy in c# programming? Any good samples and explanations on that please.
Thanks.
Regards,
Chua Wen Ching :p
|
|
|
|
|
chuawenching wrote:
static int amountopen = (0 - 500);
Hmm.. wonder, does it means we are setting a scope from 0 to 500 for integer amountopen?
Nope, it just means make amountopen = to the result of subtracting 500 from 0.
chuawenching wrote:
How does virtual keyword comes in handy in c# programming? Any good samples and explanations on that please.
Here's a link that should help: http://www.jaggersoft.com/csharp_course/16_Inheritance_files/frame.htm[^] Click on "virtual Methods".
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Thanks for the reply.
amountopen = to the result of subtracting 500 from 0.
--> subtract 500 from 0 means amountopen = -500 ???
So why can't the coder code this:
amountopen = -500
rather than
amountopen = (0-500)
What is his purpose? Thanks for the virtual link?
Is that the best site to learn oop way in c#? Must the slides does not show a complete source code. I want to learn while coding? Thanks.
Regards,
Chua Wen Ching :p
|
|
|
|
|
chuawenching wrote:
So why can't the coder code this:
amountopen = -500
rather than
amountopen = (0-500)
I don't know. If you can ask him/her, hopefully you can find out. There's no obvious answer, except perhaps the developer didn't know he/she could just write -500.
chuawenching wrote:
Is that the best site to learn oop way in c#? Must the slides does not show a complete source code. I want to learn while coding?
It's the best one I could come up with on short notice. I'm sure there are others out there that do a better job. Here's one from MSDN which may serve you better: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcoriCProgrammersReference.asp[^]. Depending on how much previous experience you have with other languages, a book on C# programming may also help.
Good luck!
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Thanks
But i feel that msdn tutorials a bit complicated. So many links here and there. And at the end i learn nothing.
Regards,
Chua Wen Ching :p
|
|
|
|
|
Hi,
a little question:
What is the default type access modifier for a class/struct?
The MCAD Study Guide I'm reading says public while a tutorial from MS'site (Dr. GUI) says internal?!?!
Oh what to believe? ;P;P
|
|
|
|
|
Internal, AFAIK.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Java heathen.
The default access is 'private', of course.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Blake Coverett wrote:
Java heathen.
Yep.
Blake Coverett wrote:
The default access is 'private', of course.
I think he was referring to the default accessibility for a class inside a namespace, not for the members of a class themselves. And according to this[^], it's internal .
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
The question is a big vague, but upon rereading it I think you are right about what he was asking. And yes indeed, the default access of a class is protected. Touche'.
*grins broadly* On the other hand... there is no 'accessibility inside a namespace' at all in C#. That is an even more blantant Java-ism. Assemblies are a protection boundary, namespaces are have no impact on accessibility whatsoever.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Yeah I was reffering to access modifiers as applied to a class or struct, for example:
public class<br />
{<br />
}
By surfing MS's site I've come to the conclusion that it's internal which is what I've always thought it was until I read the MCAD Study Guide from MS where it is clearly stated as being public ! . How can something like that slip by the technical editor?!?!
|
|
|
|
|
Does anyone know how using the Drawing.Image.Bitmap class I can read a bitmap in CMYK format, modify it, and save it preserving the CMYK attributes. Currently it reads it in just fine but when writing it converts to RGB.
|
|
|
|
|
Sorry, that's not going to happen with the Bitmap class, at least not in this revision. If you are working with CMYK data you probably need more control over your color matching then GDI+ currently provides as well.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I need to send an email containing a link ( HTML href tag ).
Currently i can succesfully send mails using these namespaces
System.Web.Mail;
System.ServiceProcess;
The message is sent using the SmtpMail.Send( msg );
I tried including a string containing a href tag in the message body but it didnt work. I also tried including a complete html document in the message body. It didn't work either.
Anyone got an idea on how to do this ?
|
|
|
|
|
Did you set the BodyFormat property of the message to MailFormat.Html?
---------------------
Marshall Rosenstein
.NET Consultant
|
|
|
|
|
No i didn't set that property...
I read your reply, tried it and it works fine !
Thanks a lot !
|
|
|
|
|
I have an application that has a form which is bound to a DataView contained within another object. The form allows be to navigate through the rows of the table in a similar way to the Binding class overview example in the MSDN documentation (i.e. I have two buttons which change the position Property of a BindingManager). Everything works fine until I try and insert a new row. The problem is that while the row inserts just fine, the DataBindingManager doesn't seem to know about it.
Example:
I have two records (1 and 2) and I add one more, the new record becomes record one (because they are sorted alphabetically) and the BindingManager position gets set to 2 (because I was looking at the old record one before). I can still navigate up to the next record (now record 3) and back to record 2 (previously 1), but I can't get to the new record at all. For some reason it won't let me set the Position property to 1!
Sorry if that's a little difficult to follow, but does anybody know what's going on here? I've tried creating a new BindingManger object, but that doesn't seem to work, I've tried recreating the DataView and that didn't help. I tried completely reloading the data from the database and that didn't work. Any ideas????
Thanks
|
|
|
|
|
I've finally hit upon the problem, so in case anybody else encounters this: The problem was that I hadn't bother to set all of the columns in my new row and some of the ones I hadn't set were supposed to be bound to controls. Because the BindingManager couldn't bind all the controls in decided to just ignore my request to go to the new record. I'm not sure if only happens with certain controls. I have textboxes, comboboxes, checkboxes and a datepicker on my form and I suspect it's probably just a subset of those that are causing the problem (probably the checkboxes and maybe the datepicker).
|
|
|
|
|
After a quick experiment I can confirm that it's both the checkboxes and the datepicker that cannot be left null. The textboxes and comboboxes don't care.
|
|
|
|
|
Hi,
I have form in which there is a panel. This Panel is filled with controls from a different .net dll .
I want to serialize this Panel only. If I serialize the whole class in the .net dll it gives me serialization errors for the other fields in the class like Form, Panel and XMLTextReader.
How can I serialize this Panel ?
Thanks,
Paul ![Cry | :((](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
There are a couple ways.
You could override the Panel , add the SerializationAttribute (it doesn't inherit) to it, then implement the ISerializable interface to override serialization (don't forget about the serialization constructor).
You could also use a ISerializationSurrogate (see docs for more details) which allows you to serialize a Type that isn't serializable. It's easy to use. After you create your formatter, set its SurrogateSelector property to an ISurrogateSelector instance, or - if already instantiated - simple add your surrogates. You could either do this for the pre-defined Panel class if you don't want to derive your own, or add surrogates for the types that aren't serializing (with one or more surrogates). Then just serialize or deserialize.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
IS there a place where I can see an example of the kind B'coz it is going to be real complex as that Panel has all kinds of controls within it !
Like Button, Label, ListBox, ComboBox, ListView , actually all controls possible !
So which method do you think would be better in handling this scenario ?
Thanks,
Paul
|
|
|
|
|
Just google for ISerializationSurrogate and see. As far as what would be easier, you could just either derive from Panel and override just the serialization stuff (and then use that Panel class in your code instead of the .NET BCL's Panel ), or use a surrogate on just the Panel type, serializing only the information you want. You could even enumerate the child controls and save the information you want from there instead of having a surrogate for each type, although then you would have to manage the nested objects yourself, which isn't necessarily easy and would most likely include a lot of string parsing.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a C# app which I want to receive input from other external sources (mainly the OS and IE) when a certain type of file or resource is launched by the user. I.E. if my app is running and someone opens up a file on the OS with the extension ".xyz" I want my running app to receive it (similar if someone clicks on that mime-type in the browser) or it to launch my app and read it if its not running.
I did some hunting around and it seems that if that type is associated with my app in the OS it will attempt to launch my application. I have code in my main method to check to see if a process for my app is already running so I have that covered. However, how do I read the stream coming in to me (standard in threw exceptions) and what is the best way to pass that to my already running app from my main method? I could have my app listening on a port but that seems a bit much. I tried playing with standard in to no avail.
Any help would be appreciated.
PS Also, if someone can inform me of the best OS way of associating my app upon install with both a specific file extension and an IE mime-type that would also be appreciated.
|
|
|
|
|
The System.Diagnostics namespace is here to help!
There is a class called Process . It allows you to use a ProcessStartInfo struct that lets you use the ShellExecuteEx API from Windows that will execute the app (or whatever is the handler) for a file extension, MIME type, etc. Basically, create a new Process object, create a new ProcessStartInfo , fill in the info in the struct and set ProcessStartpInfo.ShellExecute = true , and call Start on the Process instance with the ProcessStartInfo .
Before doing so, the Process class also defines properties for getting a StreamReader for all your standard I/O.
The documentation for the Process class has a lot of good information and examples for everything you're needing to do.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|