Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an integer
C#
int _Count = 0;
and string array string[] strImages but when i want compare these two it is saying == cannot be applied to operand of type string and string[].
Posted
Comments
Harley L. Pebley 15-Jul-14 23:37pm    
Correct. A string is one item. A string array is multiple strings. You can't compare them directly. What is it you want to do? And what's the relevance of the fact that you have an integer?
ArunRajendra 15-Jul-14 23:51pm    
What is your requirement? Why are comparing single value with array? Logically its not correct.
sp_suresh 16-Jul-14 0:32am    
please mention correct problem so that we can solve problem....

So what does the integer have to do with anything? Your question doesn't make any sense.

Of course you can't compare a string to a array of strings. How is the compiler to know exactly how you want them compared?

You're going to have to give a lot more detail about exactly what you're doing and supply the relevant code snippet.
 
Share this answer
 
String is single word, and array of string have multiple word. i.e. list of string, it neve be comparable with == sign, if u want to set index with array and a string value,
ex: str[0]==String
 
Share this answer
 
you cant compare a single string to a collection of string, if you want compare you need to make sure that you are comparing array with it's specific index, like string_array[1]==string.
That means the string at index 1 in the array is being compared with string.
 
Share this answer
 
This is not possible to compare a string with a string array. As string object holds single data while array is a collection of data at different indexes. if you want to compare a string value within an object of an array then you need to specify the index.

e.g
string val = "abc";
string[] valArray = new string[]{"abc","mno","xyz"};

val == valArray[0];

this will give you success result as value in 'val' and value at 1st index of 'valArray' are same.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900