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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:49:27+00:00 2026-06-11T22:49:27+00:00

I would like to keep my .cs files separate, mainly because I think it

  • 0

I would like to keep my .cs files separate, mainly because I think it looks neater that way. In one .cs file I have the Form.cs. I’m working in the .NET framework 2.0. So I have a different myClass.cs file with several methods. As I want users of the form to give authentication before accessing the web services called in the method, I want the information to be private.
I’ve seen in examples and tutorials that this is no problem normally within the same file. However, in my goal I want the info to be in the class.cs file.. For example I want the class in myClass.cs file to look like this (this is rough yet):

    private class SessionData
    {
        private String fTicket;
        private string otherData;

        public SessionData( String ticket, String otherData)
        {
            fTicket = ticket;
            fotherData = otherData;
        }

        public String getTicket{ return fTicket; };
    }

And then access it in the form.cs file…

    private void LogOn_Click(object sender, EventArgs e)
    {

         myClass sessInfo = new myClass();

         string myTicket = sessInfo.SessionData();
         }
    }

The problem is that because it’s private I can’t access it in Form.cs. Is it even possible to do this? I’ve seen a bunch of examples and tips but always within the same file.
This is the basic idea anyways that’s in my head. If there is another way I’m open for advice!

Do I have to make a public constructor and can someone point me to an example?

  • 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-06-11T22:49:29+00:00Added an answer on June 11, 2026 at 10:49 pm

    You could define the nested class in a seperate file for example ‘SessionData.cs’ by just wrapping it inside the partial class which should have access to it.

    public partial class Form1
    {
        private class SessionData
        {
            public void getTicket();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have one .htaccess file that can rewrite correctly on both
We have #1 and #2 spots we would like to keep, but because of
I have a number of .js files that I would like to be stored
I have some XML files on my PYTHONPATH that I would like to load
I have a small JSF app and would like to keep some state on
I have various models of which I would like to keep track and collect
Possible Duplicate: Way to have compiled python files in a separate folder? When python
I would like to keep first link as default selected with javascript, here is
I would like to keep model binding when doing ajax calls from my view.
I would like to keep an item selected, on a ListView, when the user

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.