Given the code below, will the method parameter in Bar (int y) have a value of x or 1? I understand that they are logically equivalent, but I want to understand the assignment operation.
class Program { static void Main(string[] args) { var foo = new Foo(); var x = 0; foo.Bar(x = 1); } } public class Foo { public void Bar(int y) { } }
The parameter receives the assignment value.
Consider the following code:
int x = 0; int y = (x = 1); x = 42; foo.Bar(y);
While xchanging again, ystill contains 1.
x
y
1
It is assigned to the result x=1, which is 1.
x=1
Bar, " , " ( ).
Bar
int 1.
int
. . .
x = 1 . (x=1), , x, bar.
x = 1
(x=1)
bar
x = 1 foo.bar(x)
, , x foo.
foo
, () y, , int.
, , x - , , 1, x 1, y = x = 1.
Source: https://habr.com/ru/post/1763112/More articles:How can I align the contents of a βfragileβ frame in a LaTeX Beamer presentation? - latexjQuery: How not to hide the section with the anchor in the url - jqueryHow can I exclude lambda functions in properties from code coverage? - c #method call from android service right after binding to onCreate - androiddisable hg qfinish without changeet message - mercurialHow do you close a modal window from it with a parent? - javascriptSilverlight Class Library for Windows Phone 7 Class Library - c #How to find out who created a private heap? - c ++Topic tried to unite - ruby-on-railsuse jQuery.tabs () - content overlay page - jqueryAll Articles