Because of the need, according to different conditions of a statement to realize two variable assignment,
Such as I defines two variables A and B, according to the condition, may be to B assignment, it is possible that A assignment to
So is there any C # syntax to achieve this function to introduce third-party variable C, this is likely to be A C, it is possible that B, when C=3, which is likely to be A=3, it is possible that B=3, according to the conditions to determine again, I can realize you
Practical application is in the loop, need according to the condition, to jHouseAgent or jUser assignment
JObject jHouseAgent=new JObject ();
JObject jUser=new JObject ();
The DataTable dt=DALUser. GetUserDetail (rs) [r]. "FromAccount ToInt32 ());
Then according to dt records, if you have the rs (" AgentID "]. ToInt32 () & gt; 0 is jHouseAgent assignment, such as:
JHouseAgent. Add (new JProperty (" UserID ", r (" UserID ")));
JHouseAgent. Add (new JProperty (" FacePhoto ", r [" FacePhoto "]));
JHouseAgent. Add (new JProperty (" UserName "and" r "(" UserName")));
JHouseAgent. Add (new JProperty (" TrueName ", r (" TrueName ")));
JHouseAgent. Add (new JProperty (" Mobile ", r (" Mobile ")));
If not, I still have to this
JUser. Add (new JProperty (" UserID ", r (" UserID ")));
JUser. Add (new JProperty (" FacePhoto ", r [" FacePhoto "]));
JUser. Add (new JProperty (" UserName "and" r "(" UserName")));
JUser. Add (new JProperty (" TrueName ", r (" TrueName ")));
JUser. Add (new JProperty (" Mobile ", r (" Mobile ")));
Feeling a little tired of the lock, if we can have a variable Jo acting jHouseAgent and jUser so you don't have to rewrite the code above, become like this
Jo. Add (new JProperty (" UserID ", r (" UserID ")));
Jo. Add (new JProperty (" FacePhoto ", r [" FacePhoto "]));
Jo. Add (new JProperty (" UserName "and" r "(" UserName")));
Jo. Add (new JProperty (" TrueName ", r (" TrueName ")));
Jo. Add (new JProperty (" Mobile ", r (" Mobile ")));
In the end, I don't have to worry about is given juser or jHouseAgent listed will be the two of them again