Click here to Skip to main content
14,361,357 members
   

C#

 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 17:37
memberBrian_TheLion4-Jun-19 17:37 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 16:28
memberBrian_TheLion4-Jun-19 16:28 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 16:38
memberBrian_TheLion4-Jun-19 16:38 
GeneralRe: My thoughts on C# Pin
Nathan Minier4-Jun-19 16:41
professionalNathan Minier4-Jun-19 16:41 
GeneralRe: My thoughts on C# Pin
Gerry Schmitz4-Jun-19 7:53
mveGerry Schmitz4-Jun-19 7:53 
GeneralRe: My thoughts on C# Pin
Brian_TheLion4-Jun-19 19:44
memberBrian_TheLion4-Jun-19 19:44 
QuestionHow to perform the content of a variable as a C# instruction Pin
Member 133074841-Jun-19 11:02
memberMember 133074841-Jun-19 11:02 
AnswerRe: How to perform the content of a variable as a C# instruction Pin
BillWoodruff1-Jun-19 16:33
mveBillWoodruff1-Jun-19 16:33 
First: understand that C# is a strongly typed (early binding) language where all references must be resolved by the compiler before program execution. That fundamental reality means you cannot have a REPL (read-evaluate-do-stuff-and-return-results-loop) that defers execution of arbitrary code until run-time (late-binding) [^].

However, you can kind-of implement REPL in C# by using 3rd. party libraries like CShell [^], the one built into Mono, the one available in the Roslyn compiler, and by exotic code in your own DSL.

All of these methods of achieving late-binding are expensive computationally !

What you can do is create a Dictionary with Keys of whatever, and Values of executable code; I wrote about this 13 years ago: [^]; today's C# makes the syntax a bit easier:
public Dictionary<int, Action> Instructions = new Dictionary<int, Action>
{
    {1, () => s = i * 2 },
    {2, () => lbl.Text = $"Hi dash: {string.Concat(Enumerable.Repeat('-', i * 3))}{'\\'}"},
    {3, () => timer.Dispose()},
    {4, () => MessageBox.Show("Wrong Number") }
};
If you then call Instructions [4](); in a method ... voila a modal dialog.

But, note carefully: for this code to compile the variables 'i, 's, and the Label 'lbl, and the Timer 'timer must all be defined, and any variable that is not auto-initialized ('int and 'string are auto-initialized) must have an initial value set !
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot


modified 2-Jun-19 0:27am.

GeneralRe: How to perform the content of a variable as a C# instruction Pin
Member 133074841-Jun-19 19:22
memberMember 133074841-Jun-19 19:22 
AnswerRe: How to perform the content of a variable as a C# instruction Pin
jschell2-Jun-19 9:53
memberjschell2-Jun-19 9:53 
QuestionHow To Make This Generic Pin
Kevin Marois31-May-19 12:55
professionalKevin Marois31-May-19 12:55 
AnswerRe: How To Make This Generic Pin
#realJSOP1-Jun-19 6:00
mve#realJSOP1-Jun-19 6:00 
QuestionAsk C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Dhjjf29-May-19 23:15
memberDhjjf29-May-19 23:15 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
BillWoodruff29-May-19 23:41
mveBillWoodruff29-May-19 23:41 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Eddy Vluggen29-May-19 23:56
mveEddy Vluggen29-May-19 23:56 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
OriginalGriff30-May-19 0:00
protectorOriginalGriff30-May-19 0:00 
AnswerRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
#realJSOP30-May-19 5:55
mve#realJSOP30-May-19 5:55 
GeneralRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Eddy Vluggen30-May-19 8:20
mveEddy Vluggen30-May-19 8:20 
GeneralRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
#realJSOP30-May-19 8:24
mve#realJSOP30-May-19 8:24 
PraiseRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Eddy Vluggen30-May-19 8:29
mveEddy Vluggen30-May-19 8:29 
SuggestionRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
Richard Deeming30-May-19 8:46
mveRichard Deeming30-May-19 8:46 
GeneralRe: Ask C# everyone God, about SQLiteHelper increase delete to modify the static to directly call the way Pin
#realJSOP1-Jun-19 6:02
mve#realJSOP1-Jun-19 6:02 
QuestionFile keeps getting corrupted on just one machine Pin
jkirkerx29-May-19 13:51
professionaljkirkerx29-May-19 13:51 
AnswerRe: File keeps getting corrupted on just one machine Pin
Dave Kreskowiak29-May-19 14:11
mveDave Kreskowiak29-May-19 14:11 
GeneralRe: File keeps getting corrupted on just one machine Pin
jkirkerx29-May-19 14:17
professionaljkirkerx29-May-19 14:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.