© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
35 replies
Valwex

❔ Initializing an object

Hello, what is the difference between these two lines?
var p = new Point() { X = 42, Y = 13 };
var p = new Point() { X = 42, Y = 13 };

and

var p = new Point(42, 13);
var p = new Point(42, 13);


I know that the first allows you to initiate an object, but I don't understand the difference
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

✅ Object is null after initializing
C#CC# / help
12mo ago
Object reference set to an instance of an object.
C#CC# / help
3y ago
{} vs [] when initializing an array in C#
C#CC# / help
13mo ago
✅ Object reference not set to an instance of an object.
C#CC# / help
10mo ago