सी # में इस इंटरफेस के बराबर है?जावा 8 java.util.function के C# समकक्ष क्या है। ग्राहक <>?
उदाहरण:
Consumer<Byte> consumer = new Consumer<>();
consumer.accept(data[11]);
मैं समारोह <> और कार्रवाई < आसपास खोज की है> लेकिन मुझे पता नहीं है ....
Consumer.accept के मूल जावा कोड() इंटरफेस सुंदर है सरल .. लेकिन मेरे लिए नहीं .. :-(
void accept(T t);
/**
* Returns a composed {@code Consumer} that performs, in sequence, this
* operation followed by the {@code after} operation. If performing either
* operation throws an exception, it is relayed to the caller of the
* composed operation. If performing this operation throws an exception,
* the {@code after} operation will not be performed.
*
* @param after the operation to perform after this operation
* @return a composed {@code Consumer} that performs in sequence this
* operation followed by the {@code after} operation
* @throws NullPointerException if {@code after} is null
*/
default Consumer<T> andThen(Consumer<? super T> after) {
Objects.requireNonNull(after);
return (T t) -> { accept(t); after.accept(t); };
}
यह जावा कोड है और हम ग # programer कर रहे हैं और इस इंटरफेस हमें करने के लिए सरल नहीं है:) किस यह cosumer करते हैं? –
कोई भी प्रतिनिधि प्रकार जो एक पैरामीटर लेता है और कोई मान वापस नहीं करता है वह उम्मीदवार होगा। 'एक्शन 'उनमें से एक है। –
धन्यवाद डेनिस, लेकिन मैं मिथोड स्वीकार कैसे कर सकता हूं? –