Questions tagged [method-group]
48 questions
2
votes
1 answer
ASP.NET MVC - "Cannot await 'method group'", and "namespace name 'ASPNETCoreWebApplication' could not be found"
Having an issue where return View(await _context.Reviews.ToListAsync); gives the following error: Cannot await 'method group'
I'm lead to believe that to use the return View(await _context.Reviews.ToListAsync); statement, I need to use using…

rst-2cv
- 1,130
- 1
- 15
- 31
2
votes
3 answers
How apply a method to all list members using very short linq with lambda omitted?
Say I have a List and I want to check if the members are all equal to "some string":
myList.All(v => v.Equals("some string"))
I think this would do the same (or would it?!):
myList.All("some string".Equals)
but what if instead of .Equals I want to…

Saeid
- 691
- 7
- 26
2
votes
3 answers
How to write Unit test for a group of methods in which each method depends on others?
I'm new in writing Unit test & I got stuck while writing test cases for below scenario:
Class A
{
public B createB(string name);
public B getB(string name);
public void removeB(B instance);
}
Class B
{
public B(string…

maximus
- 1,290
- 1
- 14
- 18
1
vote
1 answer
How to make a window floating on desktop?
I am trying to create a button to make a windows floating on the desktop using "topmost" but I can't assign a Boolean to the button, because it is a
method group
public partial class Form1 : Form
{
public Form1()
{
…

Trung Vũ Đức
- 17
- 4
1
vote
0 answers
How to convert an explicit operator to a method group?
My class ClassName has an operator defined:
public static explicit operator ClassName(Guid value)
{
return new ClassName(value);
}
This allows to "cast" this way:
var guids = new[] { Guid.NewGuid, Guid.NewGuid() };
var classes = guids.Select(g…

nvoigt
- 75,013
- 26
- 93
- 142
1
vote
1 answer
c# console.writeline error when adding the operator + " new"
I am using using the following code and I want to add a string to the output, but i get this error
operator '+' cannot be applied to operands of type 'method group' and
'string'.
class Program
{
static void Main(string[] args)
{
…

abdo refky
- 145
- 1
- 11
1
vote
1 answer
Cannot assign to ' ' because it is a 'method group'
I am new to C# and programming in general, for my assignment at university I have been asked to program a calculator and I am running into some trouble, here is my code:
private bool IsInfinity(long result)
{
if (result >…

Jake
- 23
- 1
- 3
1
vote
1 answer
C# Delegate as object
Disclaimer: the unit-test related info for this question is not really relevant - you can skip to "The Problem" if you're not familiar with this, but it helps set the context.
I have a class that I need to unit-test. It looks like this:
public class…

Cristian Diaconescu
- 34,633
- 32
- 143
- 233
1
vote
1 answer
Trying to add items to a ListBox, calling it a Method Group? C#
I'm trying to move items to a listbox, but it's calling my listbox a method group. The program has multiple classes. Here's what I have at the moment...
private void Button1_Click(object sender, EventArgs e)
{
ListBox1.Items.Add("Full…

TheFiloStrain
- 13
- 2
1
vote
1 answer
Using Method Group gives me The call is ambiguous between the following methods or properties:
I want to call a simple method group in Linq but I receive this error.
The call is ambiguous between the following methods or properties: 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable,…

Adam Nathan
- 160
- 1
- 7
0
votes
1 answer
How to pass one overload of a method group?
Edit: It is my own mistake (combined with some unexpected changes outside). please ignore this post and sorry for inconvenience!
Before I used to just pass this method:
string DoSomething(string)
Now the vendor added another overload like void…

elty123
- 277
- 3
- 13
0
votes
3 answers
How to check for "method group" via "sender" object?
Imagine a method like this ( in Win Forms):
//First method
private void buttonStart_Click(object sender, EventArgs e)
{
//I call another method here
this.GetData(sender, null)
}
//Second method
private void GetData(object sender,…

Dumbo
- 13,555
- 54
- 184
- 288
0
votes
2 answers
Anonymous function vs Method group - delegate to an instance method cannot have null this
I've just stumbled upon a weird issue when trying to convert from anonymous function to a method group. The example below illustrates the issue perfectly - there are 2 methods - Run() and Crash() which do everything the same, except for using…

Web Dev
- 2,677
- 2
- 30
- 41
0
votes
1 answer
How to set properties on a class to a list of method groups matching on type?
What we had before was a OracleCommand we were adding parameters to, then we'd run ExecuteReaderAsync on it to get a OracleDataReader. Then we filled lists of different objects by calling a "GetList" method that would take the reader and a method…

kleineg
- 462
- 1
- 6
- 18
0
votes
1 answer
Entity Framework method group Include does not work
I have some troubles with Loading Related Entities with a method group in EF.
In simple queries the Loading of Related Entities works ok with Include.
For example:
var result =
Repository.Query(x => x.Accepted == 0 && x.ProjectID !=…

mihai
- 2,746
- 3
- 35
- 56