Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot convert type IEnumerable to List
    primarykey
    data
    text
    <p>I have been using C# with Unity3d for a few years now, but am just starting with .NET programming. I get the error:</p> <p>Cannot implicitly convert type '<code>System.Collections.Generic.IEnumerable&lt;URL&gt;</code>' to '<code>System.Collections.Generic.List&lt;URL&gt;</code>'. An explicit conversion exists (are you missing a cast?)</p> <p>Here is my code:</p> <pre><code>namespace TestBrowserHistory { public class Test1 { public Test1() { } static void Main() { InternetExplorer myClass = new InternetExplorer(); List&lt;URL&gt; calledList = myClass.GetHistory(); Console.WriteLine("Hello!"); Console.WriteLine(calledList[1]); Console.ReadLine(); } } } public class InternetExplorer { // List of URL objects public List&lt;URL&gt; URLs { get; set; } public IEnumerable&lt;URL&gt; GetHistory() { // Initiate main object UrlHistoryWrapperClass urlhistory = new UrlHistoryWrapperClass(); // Enumerate URLs in History UrlHistoryWrapperClass.STATURLEnumerator enumerator = urlhistory.GetEnumerator(); // Iterate through the enumeration while (enumerator.MoveNext()) { // Obtain URL and Title string url = enumerator.Current.URL.Replace('\'', ' '); // In the title, eliminate single quotes to avoid confusion string title = string.IsNullOrEmpty(enumerator.Current.Title) ? enumerator.Current.Title.Replace('\'', ' ') : ""; // Create new entry URL U = new URL(url, title, "Internet Explorer"); // Add entry to list URLs.Add(U); } // Optional enumerator.Reset(); // Clear URL History urlhistory.ClearHistory(); return URLs; } } </code></pre> <p>Thanks for any help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload