none
How do you pass an out <T> parameter in a method RRS feed

  • Question

  • I would like to create a method that would pass out <T> such that I can get out string, int etc based on the out variable type

    I tried <T> like below but the compiler complains. How can you pass <T> as an out parameter?

    string value=null;
    private static bool tryGetFieldValue(string key, out <T> value ) {
        field = msg.GetField( key );
        if (field == null) {
            value = null;
            return false;
        }
        else {
            value = (T)field.Value;
            return true;
        }
    }

    Thanks

    Tuesday, August 17, 2010 8:40 PM

Answers

  • private static bool tryGetFieldValue<T>(string key, out T value )
    

    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    • Marked as answer by GG123 Tuesday, August 17, 2010 8:53 PM
    Tuesday, August 17, 2010 8:46 PM

All replies

  • private static bool tryGetFieldValue<T>(string key, out T value )
    

    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    • Marked as answer by GG123 Tuesday, August 17, 2010 8:53 PM
    Tuesday, August 17, 2010 8:46 PM
  • It worked. thanks

    Tuesday, August 17, 2010 8:53 PM