Click here to Skip to main content
16,020,305 members
Home / Discussions / C#
   

C#

 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 7:07
mveGerry Schmitz27-Nov-23 7:07 
QuestionRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Eddy Vluggen27-Nov-23 7:46
professionalEddy Vluggen27-Nov-23 7:46 
AnswerRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 15:48
mveGerry Schmitz27-Nov-23 15:48 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Eddy Vluggen28-Nov-23 0:42
professionalEddy Vluggen28-Nov-23 0:42 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Pete O'Hanlon28-Nov-23 0:48
mvePete O'Hanlon28-Nov-23 0:48 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Eddy Vluggen28-Nov-23 1:02
professionalEddy Vluggen28-Nov-23 1:02 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz28-Nov-23 6:11
mveGerry Schmitz28-Nov-23 6:11 
AnswerRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
jschell27-Nov-23 6:14
jschell27-Nov-23 6:14 
Codice Fictor wrote:
Simply put, how would I research and find the solution for these types of problems:


The general problem is that you need to map one value to another value.

The specifics of the values for each is not really relevant. The process however, obviously, is.

Being a bit more specific to your problem you want to map a 'string' (text) to something.

I can't actually tell what you want to map to. But lets say, for example, that it is enum.

Then there are two choices.
1. The string must match the name of the enum exactly. You can get by without case sensitivity but otherwise it must be the same.
2. You MUST provide code that maps from the string to the enum.

Note that there are NO other choices. Pick one.

Lets say you want to pick 1. Then you cannot name a key 'A Key' because a space is not something that can appear in a enum name. You can google for how to convert from string to enum and back again.

Or if you pick 2. There are various ways to do this. But one way actually ends up looking like solution 1. So for example you would have a table that looks like what I posted below. You would read it then match the first value. Then use the second value to create an enum (like I said similar to 1.)

'A Key', 'KeyA'
'B Key', 'KeyB'
'= Key', 'KeyEquals'


Or you could just create a switch

switch(keyValue)
{
  case "A Key": return KeyValue.KeyA;
  case "B Key": return KeyVAlue.KeyB;


There are variations on this.
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor27-Nov-23 11:12
Codice Fictor27-Nov-23 11:12 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 16:00
mveGerry Schmitz27-Nov-23 16:00 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor28-Nov-23 18:28
Codice Fictor28-Nov-23 18:28 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
jschell29-Nov-23 4:56
jschell29-Nov-23 4:56 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz29-Nov-23 5:25
mveGerry Schmitz29-Nov-23 5:25 
QuestionQuestion Pin
Mo Fouad25-Nov-23 21:35
Mo Fouad25-Nov-23 21:35 
AnswerRe: Question Pin
Richard MacCutchan25-Nov-23 22:11
mveRichard MacCutchan25-Nov-23 22:11 
AnswerRe: Question Pin
Dave Kreskowiak26-Nov-23 4:42
mveDave Kreskowiak26-Nov-23 4:42 
GeneralRe: Question Pin
Richard Andrew x6426-Nov-23 6:28
professionalRichard Andrew x6426-Nov-23 6:28 
AnswerRe: Question Pin
Gerry Schmitz26-Nov-23 9:36
mveGerry Schmitz26-Nov-23 9:36 
GeneralRe: Question Pin
jschell27-Nov-23 6:17
jschell27-Nov-23 6:17 
QuestionC# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 20:45
j k Nov202324-Nov-23 20:45 
AnswerRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 21:58
mveRichard MacCutchan24-Nov-23 21:58 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 22:13
j k Nov202324-Nov-23 22:13 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 23:22
mveRichard MacCutchan24-Nov-23 23:22 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
j k Nov202324-Nov-23 23:29
j k Nov202324-Nov-23 23:29 
GeneralRe: C# error i dont know where i going wrong it say identifer expected in line 281 Pin
Richard MacCutchan24-Nov-23 23:44
mveRichard MacCutchan24-Nov-23 23:44 

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.