how to ping a server port in the console
RTFM pingusa server address, not a port. At the port you can check is open or not - it can be done for example, using the telnet utility
examples of implementation of the program in C# to ping servers
Examples of implementation of the C# program is easy to find on freelance sites.
PS a Rather strange question from a man whose profile listed "system administrator".