← Voltar

Как привести объект AlfaTimeFrames к TimeSpan значению?

Как привести объект AlfaTimeFrames к TimeSpan значению?

Спасибо.

Este tópico foi útil?

Compartilhar tópico

Comentários (4)

Os comentários neste tópico estão bloqueados

Sergey Masyura
Sergey Masyura

watashi: Как привести объект AlfaTimeFrames к TimeSpan значению?

Спасибо.

В классе AlfaTimeFrames есть перегруженный оператор приведения типа:


/// <summary>
/// Привести объект <see cref="AlfaTimeFrames"/> к <see cref="TimeSpan"/> значению.
/// </summary>
/// <param name="timeFrame">Объект <see cref="AlfaTimeFrames"/>.</param>
/// <returns><see cref="TimeSpan"/> значение.</returns>
public static explicit operator TimeSpan(AlfaTimeFrames timeFrame)
{
	if (timeFrame == null)
		throw new ArgumentNullException("timeFrame");

	return timeFrame._value;
}

watashi
watashi
watashi Autor

_timeFrame = (TimeSpan)((ComboBoxItem)timeFrameComboBox.SelectedItem).Tag; 👍

watashi
watashi Autor

_timeFrame = (TimeSpan)((ComboBoxItem)timeFrameComboBox.SelectedItem).Tag; 👎 _timeFrame = (TimeSpan)(AlfaTimeFrames)((ComboBoxItem)timeFrameComboBox.SelectedItem).Tag; 👍

Sergey Masyura
Sergey Masyura

watashi: _timeFrame = (TimeSpan)((ComboBoxItem)timeFrameComboBox.SelectedItem).Tag; 👎 _timeFrame = (TimeSpan)(AlfaTimeFrames)((ComboBoxItem)timeFrameComboBox.SelectedItem).Tag; 👍

Вероятно, приведение к ComboBoxItem можно убрать.