Click here to Skip to main content
12,996,261 members (66,915 online)
Rate this:
Please Sign up or sign in to vote.
See more:
When I try to type all this out for a struct/structure without the bits in bold, I am getting squiggly error lines. Why is it that when I add the :this() to the code, the squiggly lines disappear? This error doesn't appear for classes but they will for structs.

 struct Line
        private Point point1 { get; set; }
        private Point point2 { get; set; }
        readonly double Length;
        readonly double Slope;
        public Line(Point p1, Point p2):this()
            point1 = p1;
            point2 = p2;
Posted 15-Oct-12 12:45pm
Updated 15-Oct-12 12:54pm
n.podbielski 15-Oct-12 19:18pm
"I am getting squiggly error lines."

Thats funny way of saying about Intellisense errors notifications.
FourCrate 15-Oct-12 19:23pm
haha I'm strange...

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Structures cannot have unitialized members.
Classes can.

Structures also have default constructor added by compiler so when you adding :this() as default constructor call, error with message that struct cannot have
uninitialized members disapper as default constructor will assign default values to members.

When you change to class, as they can have such members, error will also disappear.
FourCrate 15-Oct-12 19:36pm
n.podbielski 16-Oct-12 1:09am
No problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170609.2 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100