BestHTTP asset download I'm using the asset BestHTTP in unity and I'm downloading a few image from amazonaws to use as texture. It used to be one image, but now I have a few. 

I was not able to shorten it. When I'm trying to do it in a foreach loop loop it is misbehaving. 

Could someone help me to optimize this working code?

for (int i = 0; i &lt; tzPlayInfo.Instance.bc_gametablelist.Count; i++)
{
    dealer_img += tzPlayInfo.Instance.bc_gametablelist[i].dlrimage;
    dealer_img += ",";
}
string[] newLinks = dealer_img.Split(',');

new BestHTTP.HTTPRequest(new System.Uri("**************************.amazonaws.com/resources/" 
    + "dealer/pic/" + newLinks[0]),
    (BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res)
    =&gt;
    {
        var tex = new Texture2D(20, 20);
        tex.LoadImage(res.Data);
        uitex[0].GetComponent&lt;UITexture&gt;().mainTexture = tex;
    }).Send();

new BestHTTP.HTTPRequest(new System.Uri("**************************.amazonaws.com/resources/"
    + "dealer/pic/" + newLinks[1]),
    (BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res)
    =&gt;
    {
        var tex = new Texture2D(20, 20);
        tex.LoadImage(res.Data);
        uitex[1].GetComponent&lt;UITexture&gt;().mainTexture = tex;
    }).Send();

new BestHTTP.HTTPRequest(new System.Uri("**************************.amazonaws.com/resources/"
    + "dealer/pic/" + newLinks[2]),
    (BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res)
    =&gt;
    {
        var tex = new Texture2D(20, 20);
        tex.LoadImage(res.Data);
        uitex[2].GetComponent&lt;UITexture&gt;().mainTexture = tex;
    }).Send();

new BestHTTP.HTTPRequest(new System.Uri("**************************.amazonaws.com/resources/"
    + "dealer/pic/" + newLinks[3]),
    (BestHTTP.HTTPRequest req, BestHTTP.HTTPResponse res)
    =&gt;
    {
        var tex = new Texture2D(20, 20);
        tex.LoadImage(res.Data);
        uitex[3].GetComponent&lt;UITexture&gt;().mainTexture = tex;
    }).Send();
Instead of using a foreach here, you need to use a for-loop, since you have to know the index of the image to assign it to the correct texture.

// this line replaces the first for loop you have there
var textureLinks = tzPlayInfo.Instance.bcGameTables.Select(t =&gt; t.dlrimage).ToArray();
// verify we have enough uitex elements:
if (uitex.Length &lt; textureLinks.Length) 
{
    throw new RuntimeException("too many textures linked");
}
for (int i = 0; i &lt; textureLinks.Length; i++)
{
    new BestHTTP.HTTPRequest(new System.Uri($"**.amazonaws.com/resources/dealer/pic/{textureLinks[i]}"),
        (req, res) =&gt; {
            var tex = new Texture2D(20, 20);
            tex.LoadImage(res.Data);
            uitex[i].GetComponent&lt;UITexture&gt;().mainTexture = tex;
        }).Send();
}


There's also some words to be lost on the naming convention you use. 

dealer_img should be dealerImg, uitex should be uiTextures, bc_gametablelist should be bcGameTables, dlrimage should be dealerImage... 

In general you seem to try to shorten your names and adhere to C++ conventions. That would be fine if you were programming the graphics in C++. But since this is C#, you should be following C# convention (namely camelCase)

In the code above I made use of interpolated strings for the Uri. I also left the variable types of the lambda up for inference by the compiler. It should be smart enough to do so, if BestHTTP properly specified the generics on HTTPRequest.