Object Properties not set any issues

  • Thread starter Thread starter vital
  • Start date Start date
V

vital

Hi,

I have created an C# Class with 12 properties. I am using only two
properties. Are there any performance issues in doing that. or I have
to create a Class with only two properties. I created 12 properties
because I might use them in future.

Example:

class car
{
int vehicleNo;
int make;
int model;
 
vital said:
I have created an C# Class with 12 properties. I am using only two
properties. Are there any performance issues in doing that.

Not likely. Of course, the backing fields for the properties will still be
there, whether you've changed their values or not. But unless you're going
to have thousands of those objects around, it is hardly going to matter.
 
Not likely. Of course, the backing fields for the properties will still be
there, whether you've changed their values or not. But unless you're going
to have thousands of those objects around, it is hardly going to matter.


Why I asked it because some of the properties are of type
"HttpPostedFile". Which
I am not using now but I might use later. From ur reply I understood
it doesn't matter.
in performance. Can I use structs instead of class here
 
Why I asked it because some of the properties are of type
"HttpPostedFile". Which
I am not using now but I might use later. From ur reply I understood
it doesn't matter.

If you don't set any values, the backing variables will just have
values of null.
in performance. Can I use structs instead of class here

Why would you particularly want to? It's very unusual to create your
own structs in C#. Are these naturally "fundamental" value types?

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top