logo
down
shadow

System Threading Tasks String To String Conversion Error


System Threading Tasks String To String Conversion Error

Content Index :

System Threading Tasks String To String Conversion Error
Tag : chash , By : ianium
Date : November 29 2020, 12:01 PM

I wish this help you
I am getting an error message saying I cannot convert system.threading.tasks String to string.
public async Task<List<JobApplication>> GetApplications()
{
  var canInfo = await GetCandidates();
  var jobApplication = await GlobalVar.firebaseClient
          .Child("JobApplication")
          .OnceAsync<JobApplication>();
  return jobApplication.Select(item => new JobApplication
  {
    CandidateID = item.Object.CandidateID,
    ApplicationDate = item.Object.ApplicationDate,
    ApplicationTime = item.Object.ApplicationTime,
    CandidateName = canInfo.Find(a => a.CandidateId == item.Object.CandidateID).Name + " " + canInfo.Find(a => a.CandidateId == item.Object.CandidateID).LastName,
    NewCanID = item.Object.CandidateID.Substring(1),
    ImageURL = GetFile(item.Object.CandidateID.Substring(1) + "-One.jpg") // error
  }).ToList();
}
public async Task<List<JobApplication>> GetApplications()
{
  var canInfo = await GetCandidates();
  var jobApplication = await GlobalVar.firebaseClient
          .Child("JobApplication")
          .OnceAsync<JobApplication>();
  return jobApplication.Select(async item => new JobApplication
  {
    CandidateID = item.Object.CandidateID,
    ApplicationDate = item.Object.ApplicationDate,
    ApplicationTime = item.Object.ApplicationTime,
    CandidateName = canInfo.Find(a => a.CandidateId == item.Object.CandidateID).Name + " " + canInfo.Find(a => a.CandidateId == item.Object.CandidateID).LastName,
    NewCanID = item.Object.CandidateID.Substring(1),
    ImageURL = await GetFile(item.Object.CandidateID.Substring(1) + "-One.jpg")
  }).ToList();
  // error: the code is now trying to return Task<List<Task<JobApplication>>>
}
public async Task<List<JobApplication>> GetApplications()
{
  var canInfo = await GetCandidates();
  var jobApplication = await GlobalVar.firebaseClient
          .Child("JobApplication")
          .OnceAsync<JobApplication>();
  var result = new List<JobApplication>();
  foreach (var item in jobApplication)
  {
    result.Add(new JobApplication
    {
      CandidateID = item.Object.CandidateID,
      ApplicationDate = item.Object.ApplicationDate,
      ApplicationTime = item.Object.ApplicationTime,
      CandidateName = canInfo.Find(a => a.CandidateId == item.Object.CandidateID).Name + " " + canInfo.Find(a => a.CandidateId == item.Object.CandidateID).LastName,
      NewCanID = item.Object.CandidateID.Substring(1),
      ImageURL = await GetFile(item.Object.CandidateID.Substring(1) + "-One.jpg")
    });
  }
  return result;
}
public async Task<List<JobApplication>> GetApplications()
{
  var canInfo = await GetCandidates();
  var jobApplication = await GlobalVar.firebaseClient
          .Child("JobApplication")
          .OnceAsync<JobApplication>();
  var tasks = jobApplication.Select(async item => new JobApplication
  {
    CandidateID = item.Object.CandidateID,
    ApplicationDate = item.Object.ApplicationDate,
    ApplicationTime = item.Object.ApplicationTime,
    CandidateName = canInfo.Find(a => a.CandidateId == item.Object.CandidateID).Name + " " + canInfo.Find(a => a.CandidateId == item.Object.CandidateID).LastName,
    NewCanID = item.Object.CandidateID.Substring(1),
    ImageURL = await GetFile(item.Object.CandidateID.Substring(1) + "-One.jpg")
  }).ToList();
  var result = await Task.WhenAll(tasks);
  return result.ToList();
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Cannot implicitly convert type 'string' to 'System.Threading.Tasks.Task<string>'


Tag : chash , By : tayles
Date : March 29 2020, 07:55 AM
I wish this helpful for you The listed return type of the method is Task. You're trying to return a string. They are not the same, nor is there an implicit conversion from string to Task, hence the error.
You're likely confusing this with an async method in which the return value is automatically wrapped in a Task by the compiler. Currently that method is not an async method. You almost certainly meant to do this:
private async Task<string> methodAsync() 
{
    await Task.Delay(10000);
    return "Hello";
}
private Task<string> methodAsync() 
{
    return Task.Delay(10000)
        .ContinueWith(t => "Hello");
}
private Task<string> methodAsync() 
{
    return Task.Run(()=>
        {
            SomeLongRunningMethod();
            return "Hello";
        });
}
private Task<string> methodAsync() 
{
    return Task.Run(()=>
        {
            return SomeLongRunningMethodThatReturnsAString();
        });
}

Cannot convert from 'System.Threading.Tasks.Task' to 'System.Collections.Generic.Dictionary<string,string>'


Tag : chash , By : jaset
Date : March 29 2020, 07:55 AM
wish of those help I would advise not to use ContinueWith at all if you're already using await. The reason is the verbosity you end up with in your code.
Instead, use await where possible. The code ends up like this:
var historicalGroups = symbolList
                       .Select((x, i) => new { x, i })
                       .GroupBy(x => x.i / 100)
                       .Select(g => g.Select(x => x.x).ToArray());

var historicalTasks = historicalGroups.Select(x => Task.Run(() => 
                                       Downloads.getHistoricalStockData(x, market)))
                                      .ToArray();

var historcalStockResults = await Task.WhenAll(historicalTasks);

foreach (var dictionary in historcalStockResults)
{
    Downloads.updateSymbolsInDB(dictionary);
}
await Task.Delay(TimeSpan.FromHours(24));
public async Task StartDownload()
while (true)
{
    StartDownload().Wait();
}

Cannot implicitly convert type 'System.Threading.Tasks.Task<String> to 'string'


Tag : chash , By : Allen
Date : March 29 2020, 07:55 AM
it should still fix some issue I have a WCF Service with the method to return a string. , Try it like this:
private async void btnSignIn_Click_1(object sender, RoutedEventArgs e)
{
    Login._name = await ServiceClientObj.selectNameAsync(int.Parse(studentIdBox.Text));
    Frame.Navigate(typeof(WelcomePage));
}
private void btnSignIn_Click_1(object sender, RoutedEventArgs e)
{
    Login._name = ServiceClientObj.selectName(int.Parse(studentIdBox.Text));
    Frame.Navigate(typeof(WelcomePage));
}

SignalR error Cannot implicitly convert type 'System.Threading.Tasks.Task<object>' to 'string'


Tag : javascript , By : s8k
Date : March 29 2020, 07:55 AM
Does that help SignalR does not support return values from clients to hubs. The task returned by Clients.All will complete when all clients have been called.
If you want return values from clients, you will have to manually call the hub with the correct value and match the caller using your own message id.

Value of type 'System.Threading.Tasks.Task(Of String)' cannot be converted to 'String'


Tag : vb.net , By : David B
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Reading a C/C++ data structure in C# from a byte array
  • How should I translate from screen space coordinates to image space coordinates in a WinForms PictureBox?
  • Setting Objects to Null/Nothing after use in .NET
  • Converting ARBG to RGB with alpha blending
  • Is it better to create Model classes or stick with generic database utility class?
  • Passing enum type to Converter with integer value
  • Pool of objects with objects that are already on the scene in advance
  • StatusBar text fade-out when binding using Caliburn.Micro
  • Queryfilter on ApplicationUser in OnModelCreating in ApplicationDbContext creates StackOverflowException
  • How to get record form a different table based on a value from first table with linq expression?
  • Show data in Grid from returned model
  • Using Attributes to Override Data Model Conventions
  • Basic OOP console calculator, result Error
  • Compositon and Repository pattern
  • Multiple using statements with if condition
  • How do i increase a number by 1 in every line that contain the number 1
  • Add binding to elements that are created in codebehind
  • How to add a column in an existing AspNetUsers table
  • Order a list of elements with another list of doubles
  • How to setup a NuGet package to copy content files to output build directory?
  • In SignalR Core using ChannelWriter: Do I need to call TryComplete twice if there's an exception?
  • C# GetProcessesByName: issue with colon
  • c# wpf | create complex object with user-defined name to Serialize into JSON
  • How can I get a instance of a generic list with reflection?
  • WPF XAML - Design time and visibility of textbox
  • EF Core and MySql query is too slow
  • Getting Registered App Display Name from an App Id
  • How to get all variables from a string
  • Delete entity with all childs connected
  • Azure Build agent cant´t find class library referance
  • Initialize Nested Dictionaries in c#
  • .Net Core Binding
  • Generic event test method, preventing code duplication
  • How do I keep the ellipses in the center when the screen is resized
  • How to require a property using JsonSchema.NET?
  • C# XDocument Element/Elements returns null
  • Autofac keyed service with IEnumerable relationship type
  • Installing EntityFramework via NuGet manager
  • Always Check if there is Internet Connection Xamarin forms
  • WCF OneWay service slows down when aspNetCompatibilityEnabled is set to false
  • Can we use JsonRequestBehavior.AllowGet with [HttpPost] attribute?
  • How to customize the Setup wizard with custom forms in Visual Studio setup project
  • C# ASP.NET - Use method from another class to create labels
  • C# List IList or IEnumerable as argument
  • Parsing File with C# And Replace method
  • Losing special unicode characters in encryption (C#)
  • Getting stored procedure returned value instead of row affected
  • How can I construct HTML using NameValuePair in android?
  • Loading a pop up page in ASP.net through a js file
  • How to pass alert or notification message from controller to View?
  • C# to pause, turn on ssas server, backup cube.... how to?
  • How to execute DataTable.Select() for a column of custom class type for a particular element in that C#
  • how to connect mysql8.0 with C#
  • Passing incorrect values into MultiValueConverter by MultiBinding
  • Can i use IEnumerator as Update func?
  • How to convert API Json response to C# Array?
  • Blazor Textfield Oninput User Typing Delay
  • Performing both layout and render transform results in wrong output
  • uwp beforetextchanged cursor moving in front of text
  • How to keep duplicates from a string[] exclude words from a List and print them out
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com