Solved

accessing other classes from current class

Posted on 2008-10-12
2
164 Views
Last Modified: 2013-12-17
trying to access the method :: removeSpacesFromString();  from the program.cs  -- but this is not happening currently.

obviously, I would want to expand the number of classes, relating to different themes of code processes (grouping type of scripting/functions) -- bascially each class is a library of routines...just need to be able to access them from any class (as many methods cross-reference each other etc)
program.cs _____________________
 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;
 

namespace ConsoleApplication_AI

{

    static class Program

    {

        static void Main(string[] args)

        {

            removeSpacesFromString();

        }   

    }

}
 
 
 

parsing.cs _____________________
 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;
 

namespace ConsoleApplication_AI

{

    public class Parsing

    {

        public Parsing()

        {
 

        }
 

        public void removeSpacesFromString()

        {

            string sample = "this is my test sentence.";
 

            string sample1 = sample.Replace(" ", "* *");

            string[] words = sample1.Split('*');
 

            // array starting value == 0

            foreach (string word in words)

            {

                Console.WriteLine(word);

            }
 

            //string inputValue = "this is my first sentence.";
 

            //string[] inputWords = 

            //    inputValue.Split(new char[] { ' ', ',', ';', '.', '-', '/', '|', '\\',

            //                                  '%', '#', '@', '!', '~', '$', '^', '(',

            //                                  ')', '+', '[', ']', '{', '}', '"', ':', 

            //                                  '<', '>', '?',  '\r', '\n', '*' }, StringSplitOptions.RemoveEmptyEntries);
 

            //foreach (string inputWord in inputWords)

            //{

            //    Console.WriteLine(inputWord);

            //}
 

            //Console.WriteLine();

            //Console.WriteLine();

            //Console.Write("> Press any key to continue");

            Console.Read();

        }

    }

}

Open in new window

0
Comment
Question by:amillyard
2 Comments
 
LVL 10

Accepted Solution

by:
Marcjev earned 500 total points
ID: 22698737
A way here could be a static method in the Parsing, and refering to it as Parsing.removeSpacesFromString. But there are several ways, so you realy should get some understanding of C# and it's design paterns, by reading a book on the subject.
0
 

Author Comment

by:amillyard
ID: 22698758
Marcjev:  used the Parsing.removeSpacesFromString option -- worked 1st time :-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now