1

Two using nested together

 3 years ago
source link: https://www.codesd.com/item/two-using-nested-together.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Two using nested together

advertisements

is it same for the following two code snippets

Snippet 1:

using()
using()
{
   blah blah blah
}

Snippet 2:

using ()
{
  using ()
  {
    blah blah blah
  }
}


They are functionally the same.

See this SO question and answers for some more detail and options for using statements.

using(TypeX x = new TypeX())
using(TypeY y = new TypeY())
{
   blah blah blah
}

Is exactly the same as:

using(TypeX x = new TypeX())
{
  using(TypeY y = new TypeY())
  {
   blah blah blah
  }
}

Also, if your are initializing two variables of the same type, you can do the following:

using(TypeY y1 = new TypeY(), y2 = new TypeY())
{
   blah blah blah
}

Tags .net

Related Articles

When will you use nested locking?

I was reading in Albahari's excellent eBook on threading and came across the following scenario he mentions that "a thread can repeatedly lock the same object in a nested (reentrant) fashion" lock (locker) lock (locker) lock (locker) { // Do som

What is the difference between using nested routes and accepting_nested_attributes_for?

I may be confusing the two entirely, but I'm seeing that forms can facilitate associations using an array argument based on nested routes, ex: <%= form_for [@project, @task]... or using the fields_for helper if the parent class accepts_nested_nested_

By counting the number of times, two letters appear together

I am trying to make a Ruby program that counts the numer of times two letters appear together. This is what is written in the file I'm reading: hola chau And this is what I'm trying to get: ho;ol;la;ch;ha;au; 1;1;1;1;1;1; I can't get it to work prope

How to deduce 100 to zero using nested for loop c ++

Basically my program is to deduct 100 by two person until it is reach zero. I'm using nested for loop. 1 loop for each person as the person need to enter an integer. That integer will be deducted with 100. But the main problem is I can't repeat the 1

How to merge two data.frames together in R, referencing a lookup table

I am trying to merge two data.frames together, based on a common column name in each of them called series_id. Here is my merge statement: merge(test_growth_series_LUT, test_growth_series, by = intersect(series_id, series_id)) The error I'm getting i

How do you add two COUNTIF equations together?

How do i add two COUNTIF equations together to get a totalI assume you only want to count when the list contains both items in the same position. Example A1: =a B1: =a A2: =a B2: =b A3: =a B3: =c COUNTIF(A1:A3,"a") returns 3 COUNTIF(B1:B3,"

Using nested classes instead of multiple inheritance, C ++

I am trying to use nested classes instead of multiple inheritance. I am following the recommendations from the book but I keep getting an error in the constructor. Basically, Person is the grandfather, Student and Employee are the Parent and Teaching

Initialize the values ​​of the 2D matrix using Nested For Loops

I am trying to format an array that is the following: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] How could I initialize the two dimensional array and the values using nested for loops?I think you have a misunderstanding of two

Using nested vectors vs flattened vector outline, strange behavior

The problem For a long time I had the impression that using a nested std::vector<std::vector...> for simulating an N-dimensional array is in general bad, since the memory is not guarantee to be contiguous, and one may have cache misses. I thought it

Add two MySql variables together, a date and a number with php

I would like to add two mysql variables together using php in my website. I would like to take the "Date" and add it with "terms"(which is a set of days:: 30,60,90) to produce "Due_Date". Home.php $query = mysql_query("s

AngularJS: Keep the Dom and Model in sync when using nested JQuery outputs

How do you keep the DOM and the model in sync when using nested JQuery sortables? Say I have a Controller which is has defined as follows: function testCtrl($scope) { $scope.data = [{'name' : 'Test 1', 'index' : 0, 'values': [{'name' : 'sub test 1-1'

Combining two const char * together

I've tried many ways to do that, I got a void which is static and is on Console class i made, Void it self works fine: Console::WriteLine(const char* msg) On the other side, I got another const char* non static void which calls the Console::WriteLine

Put two SQL statements together

I am new at SQL and I am just trying to add two SQL statements together which are below. The first table is a basic make table pulling in only fields I need and then the second table is pulling the same information but appending it to the first table

Should I use nested subroutines in Perl?

I have 5 Perl files that are verification scripts for 5 different states of my environment. Each of them has at least a couple of subroutines. Till now, the number of states was limited to 5 and these worked fine. But now, I have like 20 more states

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK