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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:01:55+00:00 2026-06-18T02:01:55+00:00

I am writing a WPF application that searches, parses and writes files based on

  • 0

I am writing a WPF application that searches, parses and writes files based on some minimal user input. I have a method call (to a method in another class) in my mainwindow class that requires a number of different pieces of information parsed from two separate files. Currently, I have another method that parses the source files and returns an array of the parsed data for another function of the application. Within that method, I have some public variables to store the necessary info for the first call. This is the only way I can figure how to access those items without writing separate methods to search the parsed data for each individual piece of info I have attached some code to help clarify my current situation:

//From mainwindow.xaml.cs

private void button1_Click(object sender, RoutedEventArgs e)
        {
        string[] path = ff.Search(fw.sysName, fw.design, fw.partNumber);//From FileFinder class
        string[] parsedData = fp.Parse(path);//From FileProcessor class
        string[] summary = fw.SummaryWriter(parsedData, fw.masterList);//From FileWriter class
        Output.Text = "";
        foreach (string str in summaryvalues)
        {
            Output.Text += (str + "\n");
        }
    }

The variables used in ff.Search() and fw.SummaryWriter() are called from FileWriter.cs:

   class FileWriter
   {

    public string sysName;
    public string design;
    public string partNumber;
    public List<string> masterList = new List<string>();

    public string[] MasterWriter(string input, int source)
    {
          //Do stuff. The data for the public variables is mined from this method.

    }

    public string[] SummaryWriter(string[] parsedData, List<string> moduleMasterList)
    {
          //Do stuff
    }
}

The question I have is simply, how do I access those variables without making them public?

  • 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-18T02:01:56+00:00Added an answer on June 18, 2026 at 2:01 am

    First, rather than having public fields how about encapsulating them in public properties that expose private fields? Example:

    private string somePrivateField;
    public string SomePrivateField
    {
        get
        {
            return this.somePrivateField;
        }
        set
        {
            this.somePrivateField = value;
        }
    }
    

    See this site for info about properties

    Second, when i run into methods that may need to return multiple values, you can either make out parameters to the method or encapsulate the return values into a class of their own and just return an instance of that class:

    public void SomeMethod(int inputParameter, out int outvar1, out int outvar2)
    {
    ...
    }
    

    See this site for the out keyword

    or

    public SomeMethodOutput SomeMethod(int inputParameter)
    {
    ...
    return new SomeMethodOutput(number1, number2);
    }
    

    where SomeMethodOutput is a class with two properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some unit tests that I'm writing for a WPF application, and as
I'm writing WPF application, that's using MVVMLight. I have a DataGrid and I wanna
We are writing a WPF based application that is usually used on a touchscreen
I'm writing a WPF desktop application and have a view that needs to look
I develop an application on WPF. I have recognized that some parts of the
I have a WPF application that should be compact, with minimal possible memory footprint.
Im writing a WPF application that has a zoom and pan ability, but what
I'm writing a WPF application that uses a component, and this component returns a
I'm writing an application using WPF, and I need to make something that looks
I am writing a WPF application on WinXP and I have overridden the default

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.