I have a problem, i need to compare two TimeZOnes, one from data base and other from our system, i managed to compare both lists and create two lists of strings with only names of time zones but can´t create another lists with only the names that are equals from both lists
List<TimeZoneInfo> timeZonesInfo = TimeZoneInfo.GetSystemTimeZones().ToList();
ApiResponse<TimeZoneDTO> listOfTimeZonesFromSystem = new ApiResponse<TimeZoneDTO>();
TimeZoneDTO Obin = new TimeZoneDTO();
OracleParameter[] param = new OracleParameter[1];
param[0] = GetOracleParameter("cv_timeZone", null, OracleDbType.RefCursor, ParameterDirection.Output);
DataTable result = ExecuteDataTable(SP_Constants.GETTIMEZONE_SP, param);
listOfTimeZonesFromSystem.Response = Obin.TransformToTimeZoneDTO(result);
List<string> listStringsTimeZonesInfo = timeZonesInfo.ConvertAll(x => x.DisplayName.ToUpper()).ToList();
List<string> listStringsFromSystem = listOfTimeZonesFromSystem.Response.ConvertAll(x => x.TimeZoneName.ToUpper()).ToList();
var b = listStringsFromSystem.Any(listStringsFromSystem.Contains);
var equals = new List<string>();
if (b)
{
equals.AddRange(listStringsFromSystem.Concat(listStringsTimeZonesInfo.Contains));
}
I´m getting rror CS1503 Argument 2: cannot convert from ‘method group’ to ‘IEnumerable’
2
Answers
I couldn´t do it but did another way... My main objective was convert the time zones from ou DB to GMT but i had to have the id from .NET to use TimeZoneInfo, then convert to UTC then convert to GMT, so what i did was do it one by one, get from DB compare to what came from TimeZoneInfo.GetSystemTimeZones().ToList() then do the process... thanks all and sorry my english...
You are looking for the intersection of both lists.
Linq provides a method to get the intersection of two IEnumerables. https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.intersect
Depending on what you want to do with the result, you might be able to omit
ToList()
.