Question: Because I am creating DOM using Jquery it was difficult to copy the output so i am adding one image of code that i have captured using one tool

![enter image description here](https://i.stack.imgur.com/TKZnp.png)

i have attached hover and mouseout event to `id='nf1'` using this code

```
$("#nf"+n).hover(function(){
    $("#nf"+$(this).attr("post_id")+"post_delete").show();
});
$("#nf"+n).mouseout(function(){
    $("#nf"+$(this).attr("post_id")+"post_delete").hide();
});

```

Here n is post\_id and i am looping all post\_id got from response.This attach events but not giving expected behaviour Like when mouse over to `id='nf1post_delete'` it is hide 

Please ask if any doubts

Answer: 
This is, in general, how I'd do it. If you always use the same sequence of functions on a list, consider creating a chained function to handle that. You can also directly pass a function call inside one of the other function calls (as long as it returns a list), but that tends to look messy.

```
public List<int> DoSomethingWithList(List<int> list)
{
    //do stuff
    return list;
}

public List<int> DoSomethingElseWithList(List<int> list)
{
    //do other stuff
    return list;
}

public void SomeOtherFunction(string[] args)
{
    var list = new List<int>() { 1, 2, 3, 4 }; //create list
    list = DoSomethingWithList(list); //change list
    list = DoSomethingElseWithList(list); //change list further
}

```

If you are working with an object that has a `List<T>` field, I'd do like this:

```
public class MyBigClass
{
    private List<int> myList;
    public MyBigClass()
    {
        //instantiate list in constructor
        myList = new List<int>() { 1, 2, 3, 4 }; 
    }

    public void PublicListAdder(int val)
    {
        myList.Add(val);
    }

    private void PrivateListCleaner()
    {
        //remove all even numbers, just an example
        myList.RemoveAll(x => x % 2 == 0);
    }
}

```

You rarely need to use `ref` in C#, because it automatically handles pointers for you. You are (usually) not passing around a struct, you are passing around an object reference (which basically is a pointer).
In most cases, I would probably go with Anders' answer. Depending on your situation, another way that is worth considering is to write [extension methods](http://msdn.microsoft.com/en-us/library/bb383977.aspx) for List.

```
namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static object DoSomething(this List<T> list)
        {
            //do the something with list
        }
    }   
}

```

And then you can use it like so:

```
var list = new List<int>();
list.DoSomething();

```

In that example, `list` is passed as the parameter to the extension method.