|
Hi All,
Anybody knows why main() is called as main?
Why not someother names but Main()?
Anticipating your responses.
Thank You,
-Saran
|
|
|
|
|
|
Its name based on its compiler ,
If compiler is editable, you can change it to whatever you like ,
|
|
|
|
|
My feeling is that Microsoft wanted to have its own way of specifying the single entry point to program. And wanted to get away with traditional way !!!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
The name comes from C, where the function that holds the code for the main program is called "main", so the name has been around for at least 30 years.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am using RichTextBox class to display some text, and then I want to syntax highlight whats written to it.
So, i use Find(...) to select required text and then use SelectionFont,SelectionColor to changle font/color of the words i need.
The problem is that when i type, i have to do this when the text changes, and i actually see how text gets selected and changes it's color, and that is very annoying...
So, my question is, how to solve this problem? Maybe i can somehow disable redrawing of control till i completely highlighted control or smthing like ?
|
|
|
|
|
|
Hi EveryBody,
We know that Delegate is a Functional Pointer. But i want to pass Member name as a variable to Delegates. The example given below.
*--------------------------------------------------------------------------
using System;
namespace Delegate_concept
{
public delegate void MyFunction(int a, int b);
class Delegate_Method
{
public static void Function1 (int x, int y)
{
Console.WriteLine("Sum is"+(x+y));
}
public static void Function2 (int x, int y)
{
Console.WriteLine("Sub is"+(x-y));
}
public static void Function3(int x, int y)
{
Console.WriteLine("Mul is"+(x*y));
}
static void Main(string[] args)
{
int i = 1;
string Fstring = "Function";
string nString;
for ( i=1; i<=3; i++)
{
nString=Fstring+i.ToString();
MyFunction mObj = new MyFunction(@(nString));
mObj(20,5);
Console.Read();
}
}
}
}
*------------------------------------------------------------------------
In the above example, i am storing each function name into "nString" variable.
While creating instance, can i pass this variable name as a parameter. Because the variable name contains name of the function. Or i want to evaluvate the variable nString and execute the function name which i stored in "nString" variable.
If any solution or suggession please write to: act_ramesh@yahoo.com
Thanks
sfsad sdafasd fsadfasdf asd fsdf sdafsadsdafsda
|
|
|
|
|
Constructor MyFunction mObj = new MyFunction(void (int, int)target);
expects a target == method . You cannot provide string instead of method itself.
If you really want to call those methods by their index(Function1, Function2,...) , put them into a List<myfunction> or Dictionary<int, myfunction=""> :
Dictionary<int, myfunction=""> dFunctions = new Dictionary<int, myfunction="">();
//or
List<myfunction> lFunctions = new List<myfunction>();
//fill list/dictionary
...
//call method
for ( i=1; i<=3; i++)
{
dFunctions[i](20,5); // or lFunctions[i](20,5);
Console.Read();
}
|
|
|
|
|
I recently had a series of very good interviews with a company I was very excited about and was told I was the top candidate for the senior position. At the end of the interview I was given the assignment below and I was told to zip up the files and return them to the project manager for review when I was done. I was open in the interview that I had no experience in unit testing. I was assured this was no problem and I could omit that portion of the exercise. However, I opted to give it a shot - an opportunity to show I was a quick and willing learner when needed.
After I turned in the "assignment" to the project manager, I was told that after reviewing the code I would be passed over for the position.
I would be VERY appreciative of any feedback anyone might have as to what's wrong with my sample project? I have worked for the same small company for over 6 years and had no experience when I did, so I don't know if there's something I did that killed it for me. I bear no ill will to the company I interviewed for and I have removed any indications from any text that might indicate who the interview was with. But I still must continue to interview and if I'm doing something wrong, I want to nip it in the bud.
The assignment is below and here's a link to the project, exactly as I submitted it: Hire_Exercise.zip (179.7 Kb)
Please, don't spare my feelings, I would really appreciate some constructive criticism.
Thanks,
Mark
--------------------------------------------------------------------------------------------------
Hiring_Exercise
Development Requirements
1) Read an ascii text file named “Hire_input.txt” that contains a list of numbers with values between 0 and 100, each number separated by a cr/lf
Sample input (Hire_input.txt)
6
54
12
22
1
6
2) Sort the numbers in ascending order and write the results to an output file named “Hire_Ascending.txt”. Format the file in the same manner as the input file (cr/lf delimiters).
Sample output (Hire_Ascending.txt)
1
6
6
12
22
54
3) Group the numbers by their value and produce a histogram list providing the count of how many numbers of each value were read. Write the output to a file named “Hire_histogram.txt”, formatted using cr/lf delimiters.
Sample output (Hire_histogram.txt)
1 – 1
6 – 2
12 – 1
22 – 1
54 – 1
Additional Notes
• Name the program Hire_exercise.exe
• No user interface is required, the program will be run from the console should require no command line parameters to execute normally
• Assume that all files (input and output) will be found/created in the same directory as the program executes
• As part of the exercise, you are expected to write unit tests appropriate for the task.
• Use the development tools of your choice.
• You may not use any external libraries with the exception of standard I/O and a unit testing framework (if you choose).
• You may not use any built-in data structures such as lists, vectors, queues etc. You must build your solution using basic types such as integers, strings and arrays.
• You may not use any built-in sort or histogram functions.
• Please submit all available aspects of your work (source, buildfiles, executables, test input/output etc)
|
|
|
|
|
Haven't the foggiest idea what may have changed their mind so quickly. I looked through it, and it seems good to me. The only thing that I noticed that didn't follow the "Additional Notes" was the naming of the program to Hire_excercise.exe...
|
|
|
|
|
Thanks,
Regarding the program name, I changed the assignment text to remove the initials of the company, but didn't change the source code or output - the name of the program is what the original assignment asked for. But like I said, don't spare my feelings
|
|
|
|
|
Not sure if this is something you would consider, but why not call or email the Project Manager and ask what exactly the deal breaker was? Couldn't hurt to get some feedback so you can improve in the future...
|
|
|
|
|
Thanks, I have done that. But he said he won't be able to get back to me for a week or so. I figured I could get second opinions in the mean-time.
I guess patience isn't on my list of strong point
|
|
|
|
|
Given the constraints of the project I don't see anything really wrong with the code. It seems fairly well written, well commented (which is really nice) and uses two dimentional arrays - which is something I wouldn't have thought of. I'd have created a class to hold the number and the repetitions and store that in an object array.
For someone that's never written unit tests before your tests are fairly good. They aren't too complex, it is easy to see what each of them does. Obviously, you'd need a bit of guidance, but your give-it-a-go attitude shows me that you are willing to try new things. That, to me, is very important for a software developer. Technology moves on at breakneck speed these days and software developers need to keep up.
Obviously, without seeing the other assignments the other candidates turned in I can't say one way or another whether theres were better or not. However, a few months ago the company I work for went on a recruitment drive and it was shocking the quality of work that was handed in. We do the technical test first - and based on what I see here, I know that you'd be in the short list of the second interview. (The assignment we give is to write a small WinForms application. It is of similar complexity, but we encourage the use of what ever is in the .NET Framework).
Anyway, that's my tuppenyworth.
|
|
|
|
|
Thanks, I appreciate your feedback. Especially since I've read many of your posts and have seen that you know what you're talking about.
I had considered creating a class or struct for the histogram, but figured the simplicity and straight-forwardness of an array was a good idea. Plus, I assumed that the injunction against built-in data structures meant I had to show I new how to use an array efficiently. Once I figued I would be using nothing more than a multi-dimensional array there didn't seem any point in wrapping it in a class and going through all the work of implementing the interfaces that were already supported by arrays from the get-go.
Obviously, because I'm new to interviewing this was a bit of a blow to my ego. But from the responses to this post, I figure I can just suck it up and move on. It's all part of the process and everybody's got to go through it. Up 'til now I've been lucky to get by pretty easy, so thank you again.
Mark
|
|
|
|
|
The core thing to remember is, you have no control over who else applied. There's not necessarily a problem with your code, someone else may have come along who, for some reason, seemed a better proposition.
I would definately pursue them to ask why you didn't get the job, it shows that you're looking to improve yourself and open to feedback. It could open future doors there as well as give you some feedback on their thinking.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: The core thing to remember is, you have no control over who else applied
You're right. They didn't say that to me, they indicated their decision was based on my code. However, they were under no obligation to say their reason was that they found someone better. So that very well could be the reason.
Christian Graus wrote: I would definately pursue them to ask why you didn't get the job
Thanks, I'll make sure and follow up to make sure I get some feedback.
|
|
|
|
|
Hello Mark!
I just had a quick look threw your code.
As I only have .Net 1.1 VS2003, I couldn't open the sln, so I just looked into "Program.cs".
What confuses me is the usage of an int[] and why the code is not throwing an exception in your program (because it is doing that in my test program).
int[] list = new int[0];
...
//assign value in text file
list[i] = val; //here the null ref. exception is thrown (Is it a feature in .Net>1.1???)
I would have used an ArrayList for that.
This class implements IList (Add method) and also has a Sort method.
With a user IComparer class and the usage of the "CompareTo" method from the int class, there would be no need for the user Sort method.
Apart from that:
I like the usage of static method, the "using"-blocks and of corse the usage TryParse!
Hope my statment is not completely rubish.
All the best,
Martin
|
|
|
|
|
Martin# wrote: I would have used an ArrayList for that.
This class implements IList (Add method) and also has a Sort method.
With a user IComparer class and the usage of the "CompareTo" method from the int class, there would be no need for the user Sort method.
The additional notes state that no built-in data structures or sort functions are allowed.
|
|
|
|
|
|
Thanks,
I don't currently have VS2003 installed - that might be a good thing to check. There might have been compatibility problems - TryParse is a v2.0 method.
The use of built-in data structures (such as ArrayList) and Sort methods were explicitly forbidden in the instructions. ArrayList itself wasn't in the list of forbidden structures, but it did mention stacks, queues and lists. That's why I chose int[] - and I implemented the Expand() and Trim() methods similar to those used by ArrayList to allocate and trim the array elements as needed.
Thanks for your feedback.
|
|
|
|
|
Mark J. Miller wrote: TryParse is a v2.0 method.
This is really a good thing in 2.0!
I allways use double.TryParse!
Mark J. Miller wrote: That's why I chose int[]
I understand now!
But what about the null ref. exception I'm getting!
All the best,
Martin
|
|
|
|
|
Martin# wrote: But what about the null ref. exception I'm getting!
Unfortunately, I don't have v1.1 framework currently installed. So I'll have to check against that. When I run the project using VS2005 I don't get the NullReferenceException. So I'll be installing v1.1 later today so I can take a look at the exception and why it might be happening. I'm assuming you haven't made any changes to the input file and that the only difference between your environment and mine is the framework version - please let me know if I'm wrong.
Thanks,
Mark
|
|
|
|
|
Sorry Mark!
I didn't got the point on the ExpandArray method!
All the best,
Martin
|
|
|
|
|