C# Technique - Getting Constant Values By String

Is there any good way to convert strings like "xlSum", "xlAverage", and "xlCount" into the value they have under Microsoft.Office.Interop.Excel.XlConsolidationFunction?

I guess reflection would be slow (if its possible). There are about 10 of these constant values. I was trying to avoid a large switch statement if possible.

Answers


This is an enum so you should be able to use

using Microsoft.Office.Interop.Excel;

XlConslidationFunction func = (XlConsolidationFunction)
                               Enum.Parse( typeof(XlConsolidationFunction),
                                           stringVal );

Need Your Help

Destructor that also deallocates memory for a particular Hash Class in C++

c++ memory-management hash memory-leaks destructor

I'm in the process of learning C++ and trying to write a Hash class. Everything works great so far, except for the fact that when my program finishes using the hash class, there's a memory leak

Worklight - Invalid Login Attempts

worklight

I have been presented with a question by our IT Security department. They would like to know if there is a feature in place to disable logins after so many invalid login attempts. So my questions ...