Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

accessing other classes from current class

Posted on 2008-10-12
2
Medium Priority
?
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
Marcjev earned 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

597 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