none
'System.Array' does not contain a definition for 'Select' and no extension method 'Select'

    Question

  • I am trying to transfer some code from Windows forms c# to WPF C#

    original code =

    if (src[0].Properties.Contains("Manager"))
                    {
                        this.tbManager.Text = src[0].Properties["Manager"][0].ToString();
                        var input = src[0].Properties["Manager"][0].ToString();
                        var manager2 = input.Split(',').Select(pair => pair.Split('=').LastOrDefault()).ToArray().GetValue(0);
                        this.tbManager.Text = manager2.ToString();
                    }

    but for some reason i get an error were i have bolded the text.... var manager2 = input.Split(',').Select

    (pair => pair.Split('=').LastOrDefault()).ToArray().GetValue(0);  Any Ideas guys?  i really need this to work ASAP pelase lol 

    thank you for your help in advance :)


    Loving life since 1981 Preston Lambeth

    Friday, February 24, 2012 12:31 AM

Answers

All replies

  • Make sure to add, at the top of the file:   using System.Linq;

    Also, make sure you have a reference to System.Core.dll.

    With these two things, it should work.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Ptiwstp1 Friday, February 24, 2012 12:43 AM
    Friday, February 24, 2012 12:36 AM
  • WOW..............

    hard to not feel stupid lol....

    thank you for your time sir


    Loving life since 1981 Preston Lambeth

    Friday, February 24, 2012 12:44 AM
  • Sir,

    1 last question if you dont mind...

    Im having some issues with the transition to WPF from the windows forms.....

    for example:  In windows forms a 'ListBox' has a .text ext.....

    so i could do somethign like:  this.ListBoxComputerName.Text= string.Empty but in WPF i get an error ssaying that im missing a using directive or an assembly reference?

    HELP please lol


    Loving life since 1981 Preston Lambeth

    Friday, February 24, 2012 12:47 AM
  • For WPF, ListBox's docuemntation is here: 

    http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx 

    As it states, make sure you have a reference to PresentationFramework.dll, and include "using System.Windows.Controls;" at the top of your file.

    (The documentation always tells you what you need.  In this case, see:

    Namespace:  System.Windows.Controls
    Assembly:  PresentationFramework (in PresentationFramework.dll)


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Ptiwstp1 Friday, February 24, 2012 1:16 AM
    Friday, February 24, 2012 12:49 AM
  • Thank you again sir for your kind advice :)


    Loving life since 1981 Preston Lambeth

    Friday, February 24, 2012 1:16 AM