Questions tagged as 'extension-method'

4
answers

Why use C # extension methods?

What do I get with extension methods that I do not gain with inheritance? Simply using it as if it had the same name is tricky, since it causes more confusion than anything else.     
asked by 24.06.2016 / 13:43
3
answers

What is the System.Linq in C #?

I asked this question here in SOPT What is the equivalent of PHP's array_map in C #? And I was curious to know what this System.Linq is about. Because when I tried to use the above response code without using it, I got an error...
asked by 27.04.2016 / 17:48
2
answers

Receive variable value without passing parameter

I have the following method: private string toCamelCase(string text) { text = string.Format("{0}{1}",text.Substring(0, 1).ToLower(),text.Substring(1)); return text; } To use it I need to call it like this: toCamelCase("OlaMundo");...
asked by 26.11.2014 / 15:20
2
answers

Java 8 "default method" versus C # "extend method"

Java 8 introduces the concept of "standard method" to allow adding new functionality to an interface. C # provides "extension methods" that allow you to "add" methods (features) to existing types. Considering how they are implemented by th...
asked by 02.04.2016 / 01:05
1
answer

Definition of non-generic method?

In public partial class frmAltInfo : Form The error occurs:    Extension method must be defined in non-generic static class I do not understand what can be and how to solve. Here was the error: public static string TextNoFormatt...
asked by 23.11.2014 / 23:32
1
answer

How to force the occurrence of an event from an extension method?

I'm creating an application in C # and I'm using the INotifyPropertyChanged interface like this: public class Test: INotifyPropertyChanged { private int foo; public int Foo { get => foo; set => Set(ref foo, value); }...
asked by 04.12.2018 / 16:26
1
answer

Error creating extension for DataGridView C #?

I have already used extensions for other components and did not give this problem, you are giving error only with DataGridView . The component finds the extension, not the error, the error only displays when compiling the project. Whe...
asked by 01.06.2017 / 18:45
2
answers

How to use extensive functions in Javascript

In Javascript the primitive types have native functions, as an object of type Number has a function toString() : (1).toString(); // "1" And an array has includes() : [1, 3, 4].includes(1); // true [1, 3, 4].includes(10)...
asked by 28.01.2018 / 22:49
0
answers

How to do Mock IMemoryCache c #

I'm trying to test a class that implements IMemoryCache (IMemoryCache contains static methods which can not be mocados). This is what I tried to do: var teste = new Mock<IMemoryCache>(); mockCache.Setup(m => m.Set(It.IsAny<strin...
asked by 06.05.2018 / 13:23