Click here to Skip to main content
15,881,173 members
Home / Discussions / C#
   

C#

 
GeneralRe: calling a non static method from a static method in a dll class Pin
n.podbielski13-Oct-12 2:48
n.podbielski13-Oct-12 2:48 
QuestionArray.Contains Pin
ASPnoob12-Oct-12 20:14
ASPnoob12-Oct-12 20:14 
AnswerRe: 5C# 2008 Array.Contains Pin
n.podbielski12-Oct-12 20:19
n.podbielski12-Oct-12 20:19 
AnswerRe: Array.Contains Pin
Shameel12-Oct-12 22:50
professionalShameel12-Oct-12 22:50 
GeneralRe: Array.Contains Pin
ASPnoob13-Oct-12 0:13
ASPnoob13-Oct-12 0:13 
GeneralRe: Array.Contains Pin
Shameel13-Oct-12 4:24
professionalShameel13-Oct-12 4:24 
AnswerRe: Array.Contains Pin
KiranKumar Roy14-Oct-12 1:04
KiranKumar Roy14-Oct-12 1:04 
GeneralRe: Array.Contains Pin
DaveyM6914-Oct-12 9:47
professionalDaveyM6914-Oct-12 9:47 
KiranKumar Roy wrote:
You can use below function to check if Value exist in array or not

Not really. This is the C# forum, you have posted VB code. You are checking for a string, the OP could be searching for any type of data. You are searching an array that is created inside the method, typically he would be searching a class level variable or passing an array to a static method.

Array.IndexOf or Array.IndexOf<T> are a good call though, but no need to wrap in another method.

If you really want a separate method then extensions such as these would be better IMO:
C#
public static class Extensions
{
    public static bool Contains(this object[] array, object value)
    {
        bool result = false;
        if (array != null)
            result = Array.IndexOf(array, value) > -1;
        return result;
    }
    public static bool Contains<T>(this T[] array, T value)
    {
        bool result = false;
        if (array != null)
            result = Array.IndexOf<T>(array, value) > -1;
        return result;
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)




modified 14-Oct-12 16:01pm.

GeneralRe: Array.Contains Pin
KiranKumar Roy14-Oct-12 19:03
KiranKumar Roy14-Oct-12 19:03 
AnswerRe: Array.Contains Pin
BobJanova14-Oct-12 22:30
BobJanova14-Oct-12 22:30 
Questionprogressbar Pin
namat12-Oct-12 19:52
namat12-Oct-12 19:52 
AnswerRe: progressbar Pin
Eddy Vluggen12-Oct-12 23:46
professionalEddy Vluggen12-Oct-12 23:46 
QuestionExtendedWebBrowser2_Src.zip popup IE window,why? Pin
liyifei12312-Oct-12 16:52
liyifei12312-Oct-12 16:52 
AnswerRe: ExtendedWebBrowser2_Src.zip popup IE window,why? Pin
Dave Kreskowiak12-Oct-12 17:29
mveDave Kreskowiak12-Oct-12 17:29 
QuestionRemoval Tools Pin
TonchiVZ12-Oct-12 14:10
TonchiVZ12-Oct-12 14:10 
AnswerRe: Removal Tools Pin
Dave Kreskowiak12-Oct-12 17:27
mveDave Kreskowiak12-Oct-12 17:27 
GeneralRe: Removal Tools Pin
TonchiVZ13-Oct-12 4:53
TonchiVZ13-Oct-12 4:53 
GeneralRe: Removal Tools Pin
Dave Kreskowiak13-Oct-12 5:14
mveDave Kreskowiak13-Oct-12 5:14 
GeneralRe: Removal Tools Pin
TonchiVZ13-Oct-12 5:40
TonchiVZ13-Oct-12 5:40 
GeneralRe: Removal Tools Pin
TonchiVZ13-Oct-12 7:22
TonchiVZ13-Oct-12 7:22 
QuestionWindows Service interaction with Sys Tray icon Pin
JD8612-Oct-12 5:40
JD8612-Oct-12 5:40 
AnswerRe: Windows Service interaction with Sys Tray icon Pin
JD8612-Oct-12 5:41
JD8612-Oct-12 5:41 
AnswerRe: Windows Service interaction with Sys Tray icon Pin
Eddy Vluggen12-Oct-12 5:45
professionalEddy Vluggen12-Oct-12 5:45 
GeneralRe: Windows Service interaction with Sys Tray icon Pin
JD8612-Oct-12 5:48
JD8612-Oct-12 5:48 
GeneralRe: Windows Service interaction with Sys Tray icon Pin
Dave Kreskowiak12-Oct-12 6:08
mveDave Kreskowiak12-Oct-12 6:08 

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.