|
-
Feb 7th, 2022, 08:01 AM
#1
Thread Starter
Addicted Member
Why we use Constructor in C#
Hi.
Once again thanks for guiding me in this thread and referring me to the website from where I started to learn C#.
I've reached to OOP concepts in C#, where I am little confuse with Constructor.
Apart from this learning tutorial (mentioned above) I've gone through different forums, googling different articles about Constructor. The only thing I got that:
"A Constructor is a Special Member Function which is used to initialize data members......"
Question:
If constructor is using only for initializing values, so why don't I use pre-defined values?
Ok if pre-defined values are fixed ones so instead of this I can use simply a function and call it and it will initialize my data members etc. Possible Right?
Then I have to work with Constructor?
And, If as a programmer (new one) someone asks me that why you used Constructor? So what will be my answer? Just to initialize.....?
My understanding over OOP is very small, as I"m just going through OOP now, but its this one is not being picked by me?
I've even read real life examples in different forums, but didn't get at all.
Please guide me....
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|