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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:14:52+00:00 2026-06-02T03:14:52+00:00

Side note: I really could not think of a good title for this. Ok,

  • 0

Side note: I really could not think of a good title for this.

Ok, I am working on updating a program what was put together by a developer who did not believe in code reuse. SO i have been tasked with the job of updating and making it ‘friendly’ for future changes.

EDIT I should of said: The end users want a command prompt to see each ping. I know that using the built in ping would be a better option, but it is what they want…You guys know how that is /End Edit

I am working with a class that is implemented a couple times through out the program. (formerly there were two classes that basically did the same thing)

I decided to make an interface and implement it on the class.

(Have I lost you yet)

The method really just converts a hostname (one of the method paramaters) to an ipaddress, and spawns a command prompt to ping it. I also have a SEPARATE class that implements the interface and calls the method but instaed of passing a string(hostname) it passes an ipaddress object.

My question lies here: What is best practice when dealing with parameters that can change type? Would someone look over what I have done? It complies fine, i just want to make sure it is best practice.

// Interface that is implement twice in the program 
interface Icmd_Ping
    {
    void initilize_Proc(object target, string last_Octet);

    }


 class process_spawn : Icmd_Ping
{     
    writeLog_Delegate writeLog = new writeLog_Delegate(error_Log.write_log);

    private string ipaddress;
    public object Ipaddress
        {
        get { return ipaddress; }
        set
            {                
            IPAddress ip = value as IPAddress;
            if (ip != null)
                ipaddress = ip.ToString();
            else
                {

                try
                    {
                    formatIP format = new formatIP();
                    ipaddress = format.convert_Ip(((string)value));
                    }
                catch (Exception ex)
                    {
                    writeLog(ex);
                    }
                }   
            }
        }

    public void initilize_Proc(object target, string last_Octet = null)
        {
        if (target == null)
            throw new ArgumentNullException();

        formatIP format_IP = new formatIP();
        this.Ipaddress = target;

        Process cmd = new Process();
        ProcessStartInfo psi = new ProcessStartInfo {FileName = "cmd", UseShellExecute = false, RedirectStandardOutput = false };
        cmd.StartInfo = psi;

        if (last_Octet != string.Empty)
            psi.Arguments = string.Format("/c ping {0} -t", format_IP.format_Ip(((string)Ipaddress), last_Octet));
        if (last_Octet == string.Empty)
            psi.Arguments = string.Format("/c ping {0} -t", ((string)Ipaddress));


        cmd.Start();
        }



}

Should I convert the IPaddress in the ipaddress property? Or just make a new method and call that?

Sorry, I know its not very elegant at this point, I just want to make sure I am in the write direction before I really dive into this.

Thank every for your help.

  • 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-02T03:14:53+00:00Added an answer on June 2, 2026 at 3:14 am

    Firstly, I’d suggest using System.Net.IPAddress instead of rolling your own.
    http://msdn.microsoft.com/en-us/library/system.net.ipaddress.aspx

    Secondly, you could use System.Net.NetworkInformation.Ping to do the ICMP-Echo
    http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx

    e.g.

            IPAddress ip = IPAddress.Parse("192.168.0.1");
            Ping ping = new Ping();
    
            for (int i = 0; i < 4; ++i)
            {
                var reply = ping.Send(ip);
                Console.WriteLine("Reply from {0} Status: {1} time:{2}ms", 
                                  reply.Address, 
                                  reply.Status, 
                                  reply.RoundtripTime);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know on client side (javascript) you can use windows.location.hash but could not find
[NOTE:I am really looking for some good debugging techniques here. Perhaps some tricks or
Client side Validation and ValidationSummary is working fine for my project (MVC4 + Razor
mmmh guys, i really hope my english is good enaught to explain what i
I am really struggling with this one. I have Google'd this and tried most
Objects that are really large like, lets say a game map will outright not
This is really weird, for some reason the Id of the ViewModel is being
Scenario : There is a legacy program (Not sure what language) and I have
OK, the question title is a bit crappy, but I didn't really know how
Client side form validation becomes easiest by using jQuery. I tried all validators and

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.