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

  • SEARCH
  • Home
  • 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 556967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:58:34+00:00 2026-05-13T11:58:34+00:00

From the documentation : Unlike classes, structs can be instantiated without using a new

  • 0

From the documentation:

Unlike classes, structs can be instantiated without using a new operator.

So why am I getting this error:

Use of unassigned local variable ‘x’

When I try to do this?

        Vec2 x;
        x.X = det * (a22 * b.X - a12 * b.Y);
        x.Y = det * (a11 * b.Y - a21 * b.X);

Where Vec2 x is a struct?

  • 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-13T11:58:34+00:00Added an answer on May 13, 2026 at 11:58 am

    Well, are X and Y properties (rather than fields)? If so, that’s the problem. Until all the fields within x are definitely assigned, you can’t call any methods or properties.

    For instance:

    public struct Foo
    {
        public int x;
        public int X { get { return x; } set { x = value; } }
    }
    
    class Program
    {
        static void Main(string[] args)
        {
            Foo a;
            a.x = 10; // Valid
    
            Foo b;
            b.X = 10; // Invalid
        }
    }
    

    Is Vec2 your own type? Do you have access to the fields involved, or only the properties?

    If it’s your own type, I would strongly urge you to try to stick to immutable structs. I know managed DirectX has some mutable structs for getting as close to optimal performance as possible, but that’s at the cost of strange situations like this – and much worse, to be honest.

    I would personally give the struct a constructor taking X and Y:

     Vec2 x = new Vec2(det * (a22 * b.X - a12 * b.Y),
                       det * (a11 * b.Y - a21 * b.X));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Does your attrs.xml(in res/values folder) file look like this: <?xml… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer You could create a custom RoleProvider, here is an article… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer Try: printf("%04x",a); 0 - Left-pads the number with zeroes (0)… May 16, 2026 at 5:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Before I ask my questions, this is from Apple's documentation re: how to determine
From the documentation: If the platform supports the unsetenv() function, you can delete items
first a little bit of documentation from the jQuery validation plugin: Use submitHandler to
Here's an excerpt from java.text.CharacterIterator documentation: This interface defines a protocol for bidirectional iteration
Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on
From django documentation: js_info_dict = { 'packages': ('your.app.package',), } urlpatterns = patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
Mozilla's documentation from elementFromPoint explains that the coordinates are not in physical pixels, but
I'm reading the Core Data Utility tutorial from apple documentation and there's a part
I am working with a project that includes getting MMS from a mms-gateway and
From an old answer I have recently learned that Google Analytics, besides the traditional

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.