?
Solved

accessing other classes from current class

Posted on 2008-10-12
2
Medium Priority
?
181 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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