|
xmen_xwk wrote: i wanna know that how can i make a int that store number like 00 instead of 0
No you can not store an int like this...but while displaying you can always use string formatting to show them in whatever way you want...
Hope this helps
|
|
|
|
|
A number is a number. you're talking about a rendering detail. A number is not 'stored' in any format, you decide how it looks ( if it has leading 0s, if it's shown in hex, etc ) when you display it ( using the Format method on the string class )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You can only do this through formatting as a string for output.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
the format string in some formatting methods will do that for you.
Example:
int i=9;
Console.WriteLine(i.ToString("00"));
prints 09
|
|
|
|
|
Use the format method in the String class to show the number as you want.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Gee - 5 people have already answered this, what did your answer add ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Just now i signed in CG and i answered my suggestions for that.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
It added a nice , which none of the others did. I think flowers with an answer is the way forward on these forums.
It also knocked up his messages posted count by 1 - I reckon he's after your number one spot!! He'll be into thrash metal soon.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
Yep. Wonder if Satips is listening to Ratt, Quiet Riot or Twisted Sister right now
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
damn..!!
i forgot that i asked a question at code project and not checked my mail
but thanks guy i will try to use format
|
|
|
|
|
Good luck to you with format. Any other questions, post it on CP and don't forget to check your email
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
yep, it worked as i wanted
|
|
|
|
|
Cool deal, man
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
FolderBrowserDialog control allows to select the folder name. But I want added feature where I can type in the folder name instead of selecting the folder. How do I achieve this?
|
|
|
|
|
Probably, you will have to write on your own.
|
|
|
|
|
Hi,
I have implemented a custom membership provider. I have a class called ProviderUtility. In this class I have a method called EncodePassword.
I want to use the EncryptPassword method, but when I type MembershipProvider. then the method does not appear. Can someone please explain how do I use this method? I did use using System.Web.Security; at the top of my class.
Regards
ma se
|
|
|
|
|
Do you mean that you've written a class derived from MembershipProvider ? In your own instance methods, you should simply call EncryptPassword , without qualifying it with the MembershipProvider name (which indicates use of a static method). Optionally, to indicate that you're calling a method in a base class, you qualify it with base . This is required if your class overrides the base class method if you want the base class method to be called rather than your own.
Otherwise, EncryptPassword is a protected instance method, so it can only be called by instance methods of MembershipProvider and instance methods of classes derived from MembershipProvider . Since you cannot call it from other locations, IntelliSense does not show it in the list of available methods. If you type the name of a class followed by a dot, IntelliSense shows you a list of all public , static fields, methods, events and properties of that class (and internal static ones if the code you're working on is a member of the same assembly).
|
|
|
|
|
hai,what is the main difference between "methods" and "get" "set" properties? In properties we can assign and return values , but the same thing is possible in methods also and even calling the properties and methods is also similar.my question is why we go for properties??
thank u
dot net !!! definetely a revolution
|
|
|
|
|
Hi,
you dont need properties, but they make things easier and more readable.
which statement do you prefer:
myForm.Width+=100;
myForm.SetWidth(myForm.GetWidth()+100);
|
|
|
|
|
- Some features of C# rely on properties: i.e. design support and heavy use of attributes
- Properties are inlined (if I'm not mistaken)
- property link a set and get "method" together.
- properties are used i.e. in xml serialization (properties are serialized by default, fields not (and methods of course, too))
- I think it makes code more readable then properties stand for the state of an object where as methods stand for actions on this state.
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
Urs Enzler wrote: - Properties are inlined (if I'm not mistaken)
The IL generates get_ and set_ methods
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Urs Enzler wrote: Properties are inlined (if I'm not mistaken)
The JIT may choose to inline any method that's short enough. If a property setter or getter method is particularly long, it probably won't be inlined - the fact that it's a property is irrelevant.
The CLR doesn't really 'understand' properties or events - the compiler is responsible for compiling a call to the correct underlying functions. In C# they're always called set_Property , get_Property and add_Event , remove_Event respectively (for a property called Property and an event named Event ). The metadata links them into a single property or event. An standard event written in C# also has a field of the appropriate delegate type which is invisible to the user. It's possible to write an event which has custom add and remove methods; Windows Forms does this, making use of a list so that for example Control (which has 69 events in .NET 2.0) does not need to have 69 delegate fields unnecessarily bloating the memory footprint of each object. The feature is so useful that the implementation mostly lives in System.ComponentModel.Component 's Events property.
|
|
|
|
|
Properties and methods are semantically different.
The normal behaviour of a property is that it represents a single value in the object. Getting the value should not change the state of the object. Setting the value should not change the state of the object in any other way than is reasonable to expect for the change of that property.
A method on the other hand may take any form, contain a simple or complex process, and change the state of the object in any way.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello,
I am writing an interface and its implementation in C#. I want some events to be defined in implementation.
I want to know how to declare events in Interface???
for example the event defined in Implementation is
public delegate void OperatorBtInsertHandler();
public event OperatorBtInsertHandler OperatorBtInsertClicked;
public void OperatorBtinserted(string strAddress)
{
}
what i need to write in interface????
Gajesh
|
|
|
|
|
Hi!
event OperatorBtInsertHandler OperatorBtInsertClicked; will do.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|