Я попробовал все, но сработало только тогда, когда я сделал что-то вроде этого:
ModelState.Clear();
//This will clear the address that was submited
viewModel.Address = new Address();
viewModel.Message = "Dados salvos com sucesso!";
return View("Addresses", ReturnViewModel(viewModel));
Надеюсь, это поможет.
Выделите место для целевого массива, который использует Array.CopyTo ():
targetArray = new string[sourceArray.Length];
sourceArray.CopyTo( targetArray, 0 );
Array.Clone
и просто приведите результат. Array.Copy
или Array.CopyTo
Например:
using System;
class Test
{
static void Main(string[] args)
{
// Clone the whole array
string[] args2 = (string[]) args.Clone();
// Copy the five elements with indexes 2-6
// from args into args3, stating from
// index 2 of args3.
string[] args3 = new string[5];
Array.Copy(args, 2, args3, 0, 5);
// Copy whole of args into args4, starting from
// index 2 (of args4)
string[] args4 = new string[args.Length+2];
args.CopyTo(args4, 2);
}
}
Предположим, мы начинаем с args = {"a", "b", "c", "d", "e", "f", "g", "h"}
результаты следующие:
args2 = { "a", "b", "c", "d", "e", "f", "g", "h" }
args3 = { "c", "d", "e", "f", "g" }
args4 = { null, null, "a", "b", "c", "d", "e", "f", "g", "h" }