|
hi all,
Is object value type or reference type or can be of both type !!!!
Thanks in advance.
Gaurav
|
|
|
|
|
It's a reference type. Value types are primitive types like int,char
|
|
|
|
|
N a v a n e e t h wrote: Value types are primitive types like int,char
And any user defined struct s.
|
|
|
|
|
hi
i have created on class library project in c#.net 2.0. I want to add drop down list web server control in class library project in c#.net. But i have seen that System.Web.UI namespace is not supported in this type of project. But i have to add it anyway.
Anyone has idea or code to implement this.
Please help me out.
|
|
|
|
|
I'm not sure whether it works or not:
Try to make a custom control which wraps drop down list, and use it on your web server project.
|
|
|
|
|
i think u should add the refrence on ur project,then will see it
regards
|
|
|
|
|
It's not clear to me how to specify a time in a DateTime object. I've read the Help files completely, but there's something basic I'm missing.
I know how to GET the pieces of a DateTime object (hours, minutes, etc). How do I *change* them?
At base, I want to be able to say "create a new DateTime object reflecting the Date Oct 5, 1945 and Time 1:07 PM, UTC".
Anybody?
(Modified, meant "object" not format.
|
|
|
|
|
Hi, DateTime type has many constructors, the following one is pretty general:
DateTime (Int32, Int32, Int32, Int32, Int32, Int32)
Initializes a new instance of the DateTime structure to the specified year, month, day, hour, minute, and second.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks, Luc. There was a page in the MSDN after all - under the "DateTime" member of the "DateTime" class (I may never understand this terminology):
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref2/html/O_T_System_DateTime_.ctor.htm
|
|
|
|
|
You mean, kinda like this:
DateTime myTime = new DateTime(1945, 10, 5, 13, 7, 0, DateTimeKind.Utc);
?
EDIT: Alas, beaten to it.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Yes, I was "baffled" by the word "constructor" in the help files, apparently. Oddly enough, there's no examples of creating DateTime in any of the examples and sample code. Just deconstructing and converting them.
Your favorite word is now "baffle", although "lennet" is still pretty good.
|
|
|
|
|
JoeRip wrote: I was "baffled" by the word "constructor"
yes, also value types have constructors.
It is correct, but not very useful, to write int a=new int(7); ;
it is useful to use constructors on structs, such as DateTime.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yes, I'm way too used to using .Net objects without really understanding what they are. I see all these properties like DateTime.Hour which I can *get*, and I assume that I can *set* them, too.
Of course, the values in DateTime can only be set when they are initialized, but that wasn't occurring to me. So I was using new DateTime() , and trying to set the individual properties.
Intellisense would have shown me the constructors for "new DateTime( " if I had been paying attention, but clearly I was not.
|
|
|
|
|
Hi,
I've developed a C#.NET webservice. Is it possible to schedule it.
Also If Download is one of the operation performed by the web service
can i use the url : http://localhost/FileDownload/Service.asmx/Download?
Thanks in advance
Priya
|
|
|
|
|
Dpriya wrote: I've developed a C#.NET webservice. Is it possible to schedule it.
Also If Download is one of the operation performed by the web service
can i use the url : http://localhost/FileDownload/Service.asmx/Download?
This is a copy and paste from a post in the ASP.NET forum[^]. Are you aware that cross posting is considered rude by many people?
|
|
|
|
|
How do I run constructor without calling it's method's C# ?
for example:
class A
{
private static A _instance=new A();
private A()
{
SomeSingleTonClass.Instance.Items.Add(this);
}
public static A
{
get
{
return _instance;
}
}
}
thanks.
Dima
-- modified at 18:58 Monday 29th October, 2007
|
|
|
|
|
You might want to look at this implementation of a singleton: http://blog.colinmackay.net/archive/2007/09/05/393.aspx#395[^]
The version I have in the main blog entry is fine for single-threaded applications. The version in the comment is thread-safe.
Essentally you need to call the constructor in the public static property.
|
|
|
|
|
Now you've modified your post...
Dima.HEMEHT wrote: How do I run constructor without calling it's method's C# ?
The constructor will run when it needs to. Do you want the constructor to run at an explicit time? And if so why?
Actually, what are you trying to do with this class? It doesn't make sense...
|
|
|
|
|
Colin Angus Mackay wrote: Now you've modified your post...
Oh, that's why it didn't make any sense...
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Guffa wrote: Oh, that's why it didn't make any sense...
I don't think it made much sense the first time round either. I interpret these things as best I can...
|
|
|
|
|
The constructor will run when it needs to.- This is my problem.
I want to make abstract class, which will register it self in any collection.
But because Just In Time feature .Net runs constructor only when I reference to class.
public class MyTypesCollection //singleton
{
...
}
public abstract class TypeBase
{
public TypeBase(String name)
{
MyTypesCollection.items.add(name,this);
}
}
public MyNewType: TypeBase
{
private static _instance=new MyNewType("MyType");
public TypeBase(name as string):base(name)
{
....
}
}
If this code were used in JAVA it were initialize by itself , cause JAVA doesn't have JIT
|
|
|
|
|
Dima.HEMEHT wrote: I want to make abstract class, which will register it self in any collection.
But because Just In Time feature .Net runs constructor only when I reference to class.
That has nothing to do with the JIT compiler. The C# compiler compiles into IL code, and the purpose of the JIT compiler is to create the native machine code when the application is executed.
It's defined in the language when the values for the static members are created. It's only specified that the static constructor (which will create the object for the _instance variable) is executed before any members of the class is used. If your class is never used, the static constructor doesn't have to be executed at all.
Dima.HEMEHT wrote: cause JAVA doesn't have JIT
Yes, it does.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Ok i'm wrong.
What about answer?
|
|
|
|
|
I thought that was evident from my reply. It can't be done, as there is no guarantee that the static constructor will run if your class isn't used.
You could use reflection to loop through all the classes in all the assemblies, to look for classes that inherits your class.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|