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 966347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:08:34+00:00 2026-05-16T02:08:34+00:00

well… I’m confused about what can I do and what I can’t do in

  • 0

well… I’m confused about what can I do and what I can’t do in CLASS SCOPE.

For example

=========================

class myclass
{


  int myint = 0;

  myint = 5; *// this doesnt work. Intellisense doesn't letme work with myint... why?*

  void method()
  {
    myint = 5; *//this works. but why inside a method?*
  } 
}

==================================

class class1
{ 
 public int myint;
}

class class2
{
  class1 Z = new class1();

  Z.myint = 5; *//this doesnt work. like Z doesnt exists for intellisense*

 void method()
  {
    Z.myint = 5; *//this Works, but why inside a method?*
  }
}

Thats I make so many mistakes, I dont understand what works on class scope and what doesnt work.

I know that there are local varaibles and its life cycle. But I dont understand the so well the idea.

  • 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-16T02:08:35+00:00Added an answer on May 16, 2026 at 2:08 am

    A class can only contain declarations, initializations, and methods. It cannot contain statements of its own.

    class MyClass
    {
        int x; // a declaration: okay
        int y = 5; // a declaration with an initialization: okay
        int GetZ() { return x + y; } // a method: okay
    
        x = y; // a statement: not okay
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well this kind of n00b question but I still can't figure it out. I
Well it should work in IE, I know IE doesnt support content property anything
Well I have been thinking about this for a while, ever since I was
Well lets say i have this <table class=infoBox> <tr> <td> test </td> <td> <table>
Well im new to javascript but why does this not work, all i want
Well I read this article, however the scope bar just shows instantly, no animation.
Well, I've been screwing around with this for about 6 hours and I just
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
Well I can start the thread when I press togglebutton to ON and it
well i have a configuration like this in the components part of my config

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.