One solution, 2 projects and one problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

In one solution I have 2 projects. One project is containing the windows
form and the other conatins a public class returning a string... "Greetings
from Norway :-)"

How can I show the "greetings from Norway :-)" string in the solution with
the form...?

Any tip/trick or help appreciates.

Best regard
Hans Årsjö
 
In your project with the form, add a reference to the project with the
string. If the string is a static public member of the second project,
then after adding the reference to the first project, you should be
able to just use the fully qualified name in the form.

//in the second project
public static string Greetings = "Hello from Norway.";

//in the first project (which has a reference to the second project)
namespace WindowsApplication80
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

this.Text = WindowsApplication81.Form1.Greetings;
}
}
}
=================
Clay Burch
Syncfusion, Inc.
 
Hans - DiaGraphIT - said:
In one solution I have 2 projects. One project is containing the windows
form and the other conatins a public class returning a string... "Greetings
from Norway :-)"

How can I show the "greetings from Norway :-)" string in the solution with
the form...?

Add a reference from the UI project to the other project. In the form,
create an instance of the class (assuming it's an instance method that
returns the string) and then call the method.
 
Jon Skeet said:
Add a reference from the UI project to the other project. In the form,
create an instance of the class (assuming it's an instance method that
returns the string) and then call the method.

Thank you Jon!
In the project containing the form I've added a references to the "greeting"
project. It work just fine. But...

If the "greeting" changes. Do I need to re-add a reference or How do I renew
the reference?

Best regards
Hans
 
Hans - DiaGraphIT - said:
Thank you Jon!
In the project containing the form I've added a references to the "greeting"
project. It work just fine. But...

If the "greeting" changes. Do I need to re-add a reference or How do I renew
the reference?

Just rebuild and it'll pick up the changes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top