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

Related Questions

I know from documentation we can find distance between two CLLocation points using the
From the documentation I've found this example: We can animate any element, such as
From the documentation of UITableView / UITableViewController: If you decide to use a UIViewController
From the documentation: If the platform supports the unsetenv() function, you can delete items
As you can see from the documentation the way to start an Activity to
I'm using wikitools package to parse the wikipedia. I just copy this example from
From the documentation and this post I know execSQL() executes a single SQL statement
I have read from documentation how can I set minheight and minwidth of modal
Before I ask my questions, this is from Apple's documentation re: how to determine
From documentation, I'm creating pma_history table. This is the only part of scripts/create_tables.sql that

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.