|
Dear friends,
i have some small clarification.
//-----------------------------
public struct a
{
private string s;
public string Val
{ set { s = value; }
get
{ return s;
}
}
//----------------------------
public class a
{
private string s;
public string Val
{
set
{ s = value; }
get
{ return s; }
}
}
/---------------------------
the functionality will be like these....... (Asume that there are more then one variable and properties .... but no methods and functions)
tell me the best way of writting?
and where both can be used?
By
joe
|
|
|
|
|
=>Joe<= wrote: tell me the best way of writting?
There is no "best", both options have their own characteristics.
=>Joe<= wrote: and where both can be used?
I suggest you learn the difference between those two, and then you'll probably have a good idea when to use one or the other.
I could simply say that you want a class if you need to inherit things, but it just isn't that simple. A struct may inherit from an Interface. There, rule of thumb number one broken.
Start reading here.
I are Troll
|
|
|
|
|
Dear friend ....
Thanks for reply ... given link is well explanatory...
i am going to use class ... because as i mentioned that i have many variables..
and both of these condition made me not to use structer
-- It has an instance size smaller than 16 bytes.
-- It is immutable.
Thank You
by
Joe
|
|
|
|
|
The big differenc is that the struct version is a value type, and the class version is a reference type. In addition, a struct is a "cut-down" struct - it cannot be used as a basis for a new struct or class (it cannot be inherited).
It is realy quite important to understand the difference between value and reference types as it makes a big difference when you start passing things to methods!
The difference is a bit complex, and otheres have explianed it better than I could here, so google "value type versus reference type" and you will get a pile of descriptions.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
|
hi guys...i have at least 10 textboxes in my form which allow ony to enter numeric values..but some of them will be codes like phone codes and the other textbox will be the rest of phone number like 342 2222222...to make it i wrote that codes to the txtKod_Keypress event the below codes
private void txtKod_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar))
e.Handled = char.IsLetter(e.KeyChar);
if (txtKod.Text.Length == 3)
{
e.Handled = char.IsLetter(e.KeyChar);
e.Handled = char.IsNumber(e.KeyChar);
}
}
but it allows to enter letters after i entered 3 numbers actually allows everything...i dont know what is wrong there???
and another question do u suggest me to make a method like that and call it every time i need or to create my own numeric textbox by using Component Class ??
and i searched about masked textbox but there are underlines and not exactly the thing i wanted to see...so may i change its format ?
|
|
|
|
|
Why not just use MaskedTextBox?
The code you posted has a few quarks. Why do you set e.Handled equal to e.KeyChar being a letter if it isn't a digit? And then overwrite this value two times when the length of the textbox reaches 3?
To restrict the length to 3 the handler need only contain
e.Handled = (txtKod.Text.Length == 3);
However, doing a masked input properly is a bit more work. To get it right you need to handle pasting as well as typing, accept non-alphanumerical keys like backspace, left/right arrow key, and perhaps other things.
|
|
|
|
|
I re-read your post and see you're aware of the MaskedTextBox. But apparently not of it's PromptChar property. Set it to a space if you don't want to show the underline.
|
|
|
|
|
thanks man
i will use it as u said
|
|
|
|
|
.net framework has a maskedtextbox control.
More info can be found at:
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx
modified 27-May-14 4:58am.
|
|
|
|
|
I have a big canvas on which the image is drawn. I need to leave only the picture and cut off all unnecessary.
|
|
|
|
|
Why is your canvas so big? Why not use the size of the picture when you create the Image instance? If you don't, then the only option is to create a new insatnce the correct size and redraw the image into that, then dispose the original, big version. It would be a lot quicker (and more memory efficient) to get it right first time.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
You can create a new Bitmap and copy just the portion containing the picture to it. This is probably the simplest approach.
|
|
|
|
|
if you want crop any image, than i will suggest you to visit the link below
http://www.raiseitsolutions.com/forum/viewtopic.php?f=4&t=2
if you visit this link, you will know how to crop an image easily
thank you very much.
|
|
|
|
|
Hi,
The mapped drives of a server machine is not accessible, when i connect the server using WMI.
Please tell your suggestions, need anymore info?
My small attempt...
|
|
|
|
|
Uhhh....what? This doesn't make any sense at all.
Are you saying that you're trying to get which drives are mapped by the user logged into a particular server? In other words, are you trying to find out which shares are bein used by a user logged into a server?
|
|
|
|
|
I asked a question in the Hardware & Devices group, thought I'll throw it in here as well:
We are thinking of some Biometric integration into our app, and there seems to be some effort around standardization, does anyone have any first hand experience with an "open" API to biometrics? I would hate to have to code for each vendor etc...
(Our app will probably be a public app, so we won't know which device to target...)
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Adriaan Davel wrote: I would hate to have to code for each vendor
HA! That's what I make a living doing! I don't know anything about the biometrics field but I can speak about the facility protection market. No vendors share APIs, this forces customers to buy their hardware and software if they want to use their products. The problems start when you want to mix and match products from different vendors that all have their own command and control software. None of them communicate with each other because every company is trying to push their own software solution.
This introduces the need for integration solutions. The key to building one is to have an extremely flexible adapter layer so that new adapters can be added quickly. The goal of each adapter is to translate the data from a particular device into a common format that the rest of the application can understand so that it can remain vendor and device agnostic.
|
|
|
|
|
Hi Jimmanuel,
Thanks for the response that I was not hoping for The problem I have is that being a public website it's almost impossible to know which drivers to load as I would have to know which biometrics the person has linked...
It's starting to sound like I'm going to have to exclude biometrics...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
With a properly designed plugin architecture you could ask the user what they have plugged in and then load the proper driver.
Another possibility would be to try to connect to a device using all of the interfaces that you've developed; if they've linked to one that you support then one connection attempt will succeed and then you know what they have
|
|
|
|
|
I'm thinking of having an "Identify" button (that will loop through my know drivers etc), and a drop down to select from. Asking users is normally quite a pain as you have to give them instructions on how to figure out on all the different operating systems etc (target market is the less technically skilled public )
Thanks for the inputs
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
last night i have developed a small window application, having lot of insert and select scripts...
it runs fine for 3 times but when i run it 4th time it gives me Error "Out Of Memory Exception"
i obsvered that in my task manager Sqlserver.exe process occupies memory around 167000K .
then i killed it. and again run the code, this time it occupy 12000K memory.
again i run it...the memory increases and stops at 87125K
All It means i the C#.net objets are not disposed well.....i have tried for
GC.GetTotalMemory() but failed....???
what should i do ???
how can i release objects ??? or is there any other problem ???
thanks in advance
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Are you using the Dispose method on objects you no longer need? I found an obscure reference to a quirk I never considered on Google about Forms that are never garbage collected. It seems that a Form that is hidden will never be released by the Close method; you have to use Dispose to free the memory. It may be that this problem extends to other classes, as well.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi Roger,
if your app keeps a reference to a hidden Form, the Form stays alive, and you can use myForm.Show() to show it again. That is normal. And your app always keeps such reference, see Application.OpenForms, unless you either call Close() or Dispose() on said Form.
Here is some test code to confirm that:
public override void Test(int arg) {
using (Form f=new Form()) {
f.Text="my latest form";
f.Show();
listForms("Form shown");
f.Hide();
listForms("Form hidden");
}
GC.Collect();
listForms("Collected");
}
private void listForms(string title) {
log("List of forms: "+title);
int i=0;
foreach (Form f in Application.OpenForms) {
log(" Form "+i+" text="+f.Text);
i++;
}
log("Found "+i+" forms");
}
|
|
|
|
|
This much I knew. What surprised me, and I wish I could find the link again, was an article that explained that if Close() is called on a hidden Form, it doesn't work, nor does it emit an error. At least, not reliably. The Dispose() method does force the removal of the hidden form, so I've taken to using Dispose() whenever I'm done with a Form object. Damnation - I kept that article in an IE tab for weeks until IE finally committed a sin it didn't know how to cover up and closed itself.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|