Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1868040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:38:09+00:00 2026-05-17T06:38:09+00:00

public class Customer { public int CustomerId { get; set; } public string FirstName

  • 0
 public class Customer
    {
        public int CustomerId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

    public struct Customer
    {
        public int CustomerId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:38:10+00:00Added an answer on May 17, 2026 at 6:38 am

    Your second snippet is a mutable struct. That’s a really bad idea, IMO – they behave oddly in various different situations, as values can be copied when you may not expect them to be.

    You could create immutable structs of course, and there are times when that’s appropriate – but personally I find the reference type behaviour more natural usually. With structs, you also need to worry about the fact that whatever constructors you put in place, it’s always possible to set a variable to the default value – so the fields will be zero for numeric types, null for reference types etc. It’s annoying to have to deal with the possibility of an invalid object everywhere, whereas with classes you can add appropriate validation to the constructor (or factory methods) to make sure that the only thing you need to worry about is a null reference.

    The efficiency argument ends up tricky, as there are pros and cons on both sides, depending on exactly what you do with the objects.

    To cut a long answer short (too late?) – I would use classes by default; save value types for things which are natural individual values (“an instant in time”, or “an integer” for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

given: public class Customer { public int Id { get; set; } public string
Say you have two classes, order and customer: public class Customer{ public int CustomerId
public class MyClass { public string MyProperty{ get; set; } Now, I would like
Given the following POCO Code First Entities public class Customer { public int CustomerId
Here is one of my Entityclasses: public class Customer { public int Id {
public class Order { static Customer cust = new Customer(); string sEmpty = ;
I have an entity Customer public class Customer { public virtual int ID {
I have the following Entity Framework POCO classes: public class Customer { public int
I have a Customer class defined like this: @Entity public class Customer { //...
This is an extract of the JPA entities schema @Entity @Table(name=customer) public class Customer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.