Solved

C# Main () return string

Posted on 2007-04-09
2
1,494 Views
Last Modified: 2012-06-27
Can Main in C# return a String?  I'm trying to do that and changed it from static void to static string and i get the following error:
MainString.exe' does not contain a static 'Main' method suitable for an entry point      MainString

Any help would be greatly appreciated.

--Rob
0
Comment
Question by:rkellow
2 Comments
 
LVL 3

Accepted Solution

by:
JipFromParis earned 500 total points
ID: 18878865
No, you can't. The Main function result must be handled at the system level (Windows) and the system defines the entry function of a program as returning an integer. Returning anything else than an integer is impossible. FYI, when you define the Main function with a void return type, the program will actually return a 0 value.
0
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18878881
Where do you need to return the string to since Main is the starting point for an application?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

777 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